我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用flask_login.current_user.is_superuser()。
def is_accessible(self): return ( not AUTHENTICATE or (not current_user.is_anonymous() and current_user.is_superuser()) )
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
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
def is_accessible(self): if current_user.is_authenticated and current_user.is_superuser: return True return False