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


Python current_user.is_authenticated方法代碼示例

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


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

示例1: inject_user_tags

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def inject_user_tags():
    if not current_user.is_authenticated:
        return {
            "user_tags": None
        }
    else:
        user_tags = Tag.query.filter(Tag.user == current_user.id,
                                     Tag.count > 0).all()
        user_tags.sort(key=lambda k: k.text.lower())
        user_tags = [{'text': tag.text.encode('utf-8'),
                      'value': tag.text.encode('utf-8'),
                      'count': tag.count} for tag in user_tags if
                     tag.text != '']
        return {
            "user_tags": user_tags
        } 
開發者ID:dhamaniasad,項目名稱:crestify,代碼行數:18,代碼來源:manager.py

示例2: is_accessible

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [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: _handle_view

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def _handle_view(self, name, **kwargs):
        """
        Override builtin _handle_view in order to redirect users when a
        view is not accessible.
        """
        if not self.is_accessible():
            if current_user.is_authenticated:
                # permission denied
                abort(403)
            else:
                # login
                return redirect(url_for('security.login', next=request.url)) 
開發者ID:beavyHQ,項目名稱:beavy,代碼行數:14,代碼來源:admin_model_view.py

示例4: is_accessible

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

示例5: index

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [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

示例6: inject_bmark_count

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def inject_bmark_count():
    if current_user.is_authenticated:
        bookmark_count = Bookmark.query.filter_by(user=current_user.id, deleted=False).count()
        return dict(bookmark_count=bookmark_count)
    return dict(bookmark_count=0) 
開發者ID:dhamaniasad,項目名稱:crestify,代碼行數:7,代碼來源:manager.py

示例7: view

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def view(map_identifier):
    topic_store = get_topic_store()

    collaboration_mode = None
    if current_user.is_authenticated:  # User is logged in
        is_map_owner = topic_store.is_topic_map_owner(map_identifier, current_user.id)
        if is_map_owner:
            topic_map = topic_store.get_topic_map(map_identifier, current_user.id)
        else:
            topic_map = topic_store.get_topic_map(map_identifier)
        if topic_map is None:
            abort(404)
        collaboration_mode = topic_store.get_collaboration_mode(map_identifier, current_user.id)
        # The map is private and doesn't belong to the user who is trying to
        # access it
        if not topic_map.published and not is_map_owner:
            if not collaboration_mode:  # The user is not collaborating on the map
                abort(403)
    else:  # User is not logged in
        topic_map = topic_store.get_topic_map(map_identifier)
        if topic_map is None:
            abort(404)
        if not topic_map.published:  # User is not logged in and the map is not published
            abort(403)

    return render_template("map/view.html", topic_map=topic_map) 
開發者ID:brettkromkamp,項目名稱:contextualise,代碼行數:28,代碼來源:map.py

示例8: is_accessible

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

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

        return False 
開發者ID:ozhiwei,項目名稱:SmartProxyPool,代碼行數:10,代碼來源:views.py

示例9: _handle_view

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def _handle_view(self, name, **kwargs):
        if current_user.is_authenticated:
            pass
        else:
            return redirect(url_for('security.login', next=request.url)) 
開發者ID:ozhiwei,項目名稱:SmartProxyPool,代碼行數:7,代碼來源:views.py

示例10: index

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def index(self):
        if not current_user.is_authenticated:
            return redirect(url_for('security.login'))
        return super(ProxyPoolAdminIndexView, self).index() 
開發者ID:ozhiwei,項目名稱:SmartProxyPool,代碼行數:6,代碼來源:views.py

示例11: write_activity_on_follow

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def write_activity_on_follow(follow, **kwargs):
    if current_user.is_authenticated:
        if isinstance(follow.following, Dataset):
            UserFollowedDataset.emit(follow.following)
        elif isinstance(follow.following, Reuse):
            UserFollowedReuse.emit(follow.following)
        elif isinstance(follow.following, Organization):
            UserFollowedOrganization.emit(follow.following)
        elif isinstance(follow.following, User):
            UserFollowedUser.emit(follow.following) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:12,代碼來源:activities.py

示例12: write_activity_on_discuss

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def write_activity_on_discuss(discussion, **kwargs):
    if current_user.is_authenticated:
        if isinstance(discussion.subject, Dataset):
            UserDiscussedDataset.emit(discussion.subject)
        elif isinstance(discussion.subject, Reuse):
            UserDiscussedReuse.emit(discussion.subject) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:8,代碼來源:activities.py

示例13: on_user_created_reuse

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def on_user_created_reuse(reuse):
    if not reuse.private and current_user and current_user.is_authenticated:
        UserCreatedReuse.emit(reuse, reuse.organization) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:5,代碼來源:activities.py

示例14: on_user_updated_reuse

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def on_user_updated_reuse(reuse):
    if not reuse.private and current_user and current_user.is_authenticated:
        UserUpdatedReuse.emit(reuse, reuse.organization) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:5,代碼來源:activities.py

示例15: on_user_deleted_reuse

# 需要導入模塊: from flask_security import current_user [as 別名]
# 或者: from flask_security.current_user import is_authenticated [as 別名]
def on_user_deleted_reuse(reuse):
    if not reuse.private and current_user and current_user.is_authenticated:
        UserDeletedReuse.emit(reuse, reuse.organization) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:5,代碼來源:activities.py


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