當前位置: 首頁>>代碼示例>>Python>>正文


Python current_user.has_role方法代碼示例

本文整理匯總了Python中flask_security.current_user.has_role方法的典型用法代碼示例。如果您正苦於以下問題:Python current_user.has_role方法的具體用法?Python current_user.has_role怎麽用?Python current_user.has_role使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask_security.current_user的用法示例。


在下文中一共展示了current_user.has_role方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: revert

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def revert(link):
    """ the link to make the latest version the one selected.
    """
    if wiki_for(link).locked and not current_user.has_role('admin'):
        flash('Wiki page locked.')
        return current_app.login_manager.unauthorized()

    latest = request.args.get('latest', None)
    if latest is not None:
        oldone = wiki_for(link)
        newone = (current_session
                  .query(Wiki)
                  .filter(Wiki.link == link)
                  .filter(Wiki.id == int(latest))
                  .first())

        oldone.latest = 0
        newone.latest = 1
        current_session.add(newone)
        current_session.add(oldone)
        current_session.commit()
        return redirect(url_for('wiki.index', link=link, id=newone.id))
    else:
        abort(404) 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:26,代碼來源:views.py

示例2: is_accessible

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def is_accessible(self):
        if not current_user.is_active or not current_user.is_authenticated:
            return False

        if current_user.has_role('admin'):
            return True

        return False 
開發者ID:beavyHQ,項目名稱:beavy,代碼行數:10,代碼來源:admin_model_view.py

示例3: can_do_stuff_with_job

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_do_stuff_with_job(current_user, owner):
    return current_user.has_role('admin') or current_user.email == owner.email 
開發者ID:fkie-cad,項目名稱:LuckyCAT,代碼行數:4,代碼來源:Jobs.py

示例4: jobs_show

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def jobs_show():
    filtered_jobs = []
    if current_user.has_role('admin'):
        filtered_jobs = Job.objects
    else:
        for job in Job.objects:
            if job.owner:
                if job.owner.email == current_user.email:
                    filtered_jobs.append(job)

    return flask.render_template("jobs_show.html", jobs=filtered_jobs) 
開發者ID:fkie-cad,項目名稱:LuckyCAT,代碼行數:13,代碼來源:Jobs.py

示例5: validate

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def validate(self):
        if not super(GenerateApiKeyForm, self).validate():  # pragma: no cover
            return False

        if not current_user.has_role("developer"):
            return False

        return True 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:10,代碼來源:frontend.py

示例6: api_auth_required

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def api_auth_required(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        if request.authorization and request.authorization.type == "basic":
            user = user_datastore.find_user(api_key=request.authorization.username)
            if user and user.has_role("developer"):
                _request_ctx_stack.top.user = user
                identity_changed.send(
                    current_app._get_current_object(), identity=Identity(user.id)
                )
                return f(*args, **kwargs)
        abort(401)

    return wrapper 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:16,代碼來源:api.py

示例7: is_accessible

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def is_accessible(self):
        return current_user.is_authenticated and current_user.has_role("admin") 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:4,代碼來源:admin.py

示例8: can_create

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_create(self):
        return current_user.has_role("package_admin") 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:4,代碼來源:admin.py

示例9: can_edit

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_edit(self):
        return current_user.has_role("package_admin") 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:4,代碼來源:admin.py

示例10: can_delete

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_delete(self):
        return current_user.has_role("admin") 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:4,代碼來源:admin.py

示例11: can_sign

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_sign(self):
        return current_user.has_role("admin") 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:4,代碼來源:admin.py

示例12: can_unsign

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def can_unsign(self):
        return current_user.has_role("admin")

    # Hooks 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:6,代碼來源:admin.py

示例13: get_query

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def get_query(self):
        if not current_user.has_role("package_admin"):
            return (
                super(VersionView, self)
                .get_query()
                .join(self.model.package)
                .join(Package.maintainers)
                .filter(User.id == current_user.id)
            )
        return super(VersionView, self).get_query() 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:12,代碼來源:admin.py

示例14: get_count_query

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def get_count_query(self):
        if not current_user.has_role("package_admin"):
            return (
                super(VersionView, self)
                .get_count_query()
                .join(self.model.package)
                .join(Package.maintainers)
                .filter(User.id == current_user.id)
            )
        return super(VersionView, self).get_count_query()

    # Actions 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:14,代碼來源:admin.py

示例15: index

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import has_role [as 別名]
def index(self):
        if not current_user.is_authenticated:
            return redirect(url_for("security.login"))
        if not any(map(current_user.has_role, ("developer", "package_admin", "admin"))):
            abort(403)
        return super(IndexView, self).index() 
開發者ID:SynoCommunity,項目名稱:spkrepo,代碼行數:8,代碼來源:admin.py


注:本文中的flask_security.current_user.has_role方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。