Python flask_login.current_user 模块,is_superuser() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用flask_login.current_user.is_superuser()

项目:incubator-airflow-old    作者:apache    | 项目源码 | 文件源码
def is_accessible(self):
        return (
            not AUTHENTICATE or
            (not current_user.is_anonymous() and current_user.is_superuser())
        )
项目:flask-maple    作者:honmaple    | 项目源码 | 文件源码
def is_admin(func):
    @wraps(func)
    def decorated_view(*args, **kwargs):
        if current_user.is_authenticated and current_user.is_superuser:
            return func(*args, **kwargs)
        abort(403)

    return decorated_view
项目:NZ-ORCID-Hub    作者:Royal-Society-of-New-Zealand    | 项目源码 | 文件源码
def is_accessible(self):
        """Verify if the task view is accessible for the current user."""
        if not super().is_accessible():
            return False

        # Added the feature for superuser to access task related to all research organiastion
        if current_user.is_superuser:
            return True

        if request.method == "POST" and request.form.get("rowid"):
            # get the first ROWID:
            rowid = int(request.form.get("rowid"))
            task_id = self.model.get(id=rowid).task_id
        else:
            task_id = request.args.get("task_id")
            if not task_id:
                _id = request.args.get("id")
                if not _id:
                    flash("Cannot invoke the task view without task ID", "danger")
                    return False
                else:
                    task_id = self.model.get(id=_id).task_id

        try:
            task = Task.get(id=task_id)
            if task.org.id != current_user.organisation.id:
                flash("Access denied! You cannot access this task.", "danger")
                return False

        except Task.DoesNotExist:
            flash("The task deesn't exist.", "danger")
            abort(404)

        return True
项目:maple-file    作者:honmaple    | 项目源码 | 文件源码
def is_accessible(self):
        if current_user.is_authenticated and current_user.is_superuser:
            return True
        return False
项目:airflow    作者:apache-airflow    | 项目源码 | 文件源码
def is_accessible(self):
        return (
            not AUTHENTICATE or
            (not current_user.is_anonymous() and current_user.is_superuser())
        )