当前位置: 首页>>代码示例>>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;未经允许,请勿转载。