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


Python flask_principal.AnonymousIdentity方法代碼示例

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


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

示例1: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout():
    logout_user()
    identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity())

    return redirect(url_for('.login')) 
開發者ID:Tianny,項目名稱:incepiton-mysql,代碼行數:7,代碼來源:views.py

示例2: logout_user

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout_user():
    """Logs out the current user.

    This will also clean up the remember me cookie if it exists.

    This sends an ``identity_changed`` signal to note that the current
    identity is now the `AnonymousIdentity`
    """

    for key in ("identity.name", "identity.auth_type", "fs_paa", "fs_gexp"):
        session.pop(key, None)

    # Clear csrf token between sessions.
    # Ideally this would be handled by Flask-WTF but...
    # We don't clear entire session since Flask-Login seems to like having it.
    csrf_field_name = find_csrf_field_name()
    if csrf_field_name:
        session.pop(csrf_field_name, None)
        # Flask-WTF 'caches' csrf_token - and only set the session if not already
        # in 'g'. Be sure to clear both. This affects at least /confirm
        g.pop(csrf_field_name, None)
    session["fs_cc"] = "clear"
    identity_changed.send(
        current_app._get_current_object(), identity=AnonymousIdentity()
    )
    _logout_user() 
開發者ID:Flask-Middleware,項目名稱:flask-security,代碼行數:28,代碼來源:utils.py

示例3: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout():
    """GET /signout: sign out user
    """
    logout_user()

    # tell flask-principal the user is anonymous
    identity_changed.send(current_app._get_current_object(),
                          identity=AnonymousIdentity())

    return redirect(url_for('content.home')) 
開發者ID:muicss,項目名稱:flaskapp,代碼行數:12,代碼來源:auth.py

示例4: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout():

	logout_user()

	# Remove session keys set by Flask-Principal
	for key in ('identity.id', 'identity.auth_type'):
		session.pop(key,None)

	identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity())

	return NO_CONTENT 
開發者ID:AstroPrint,項目名稱:AstroBox,代碼行數:13,代碼來源:__init__.py

示例5: signout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def signout(self, hasSessionContext = True):
		if hasSessionContext:
			from flask import session

			logout_user()

			for key in ('identity.name', 'identity.auth_type'):
				session.pop(key, None)

			identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity())

		self.remove_logged_user() 
開發者ID:AstroPrint,項目名稱:AstroBox,代碼行數:14,代碼來源:cloud.py

示例6: logout_user

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout_user(self):
        """
        Logs out the current user and cleans up the remember me cookie (if any).

        Sends signal `identity_changed` (from flask_principal).
        Sends signal `user_logged_out` (from flask_login).
        """

        for key in ('identity.name', 'identity.auth_type'):
            session.pop(key, None)
        _logout_user()
        identity_changed.send(app._get_current_object(),
                              identity=AnonymousIdentity()) 
開發者ID:briancappello,項目名稱:flask-unchained,代碼行數:15,代碼來源:security_service.py

示例7: post

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def post(self):
        """
        Request that the current user be signed out.
        """
        # Invalidate all sessions for the user.
        model.user.invalidate_all_sessions(get_authenticated_user())

        # Clear out the user's identity.
        identity_changed.send(app, identity=AnonymousIdentity())

        # Remove the user's session cookie.
        logout_user()

        return {"success": True} 
開發者ID:quay,項目名稱:quay,代碼行數:16,代碼來源:user.py

示例8: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout():
    logout_user()

    # Notify flask principal that the user has logged out
    identity_changed.send(current_app._get_current_object(),
                          identity=AnonymousIdentity())

    return redirect(url_for('index.render_feed')) 
開發者ID:airbnb,項目名稱:knowledge-repo,代碼行數:10,代碼來源:auth.py

示例9: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout(self):
        logout_user()
        identity_changed.send(
            current_app._get_current_object(), identity=AnonymousIdentity()) 
開發者ID:honmaple,項目名稱:maple-bbs,代碼行數:6,代碼來源:models.py

示例10: logout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def logout():
    logout_user()
    # Remove session keys set by Flask-Principal
    for key in ('identity.name', 'identity.auth_type'):
        session.pop(key, None)

    # Tell Flask-Principal the user is anonymous
    identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity())

    flash('You have been logged out', 'success')
    return redirect(url_for('accounts.login')) 
開發者ID:GitMarkTeam,項目名稱:gitmark,代碼行數:13,代碼來源:views.py

示例11: signout

# 需要導入模塊: import flask_principal [as 別名]
# 或者: from flask_principal import AnonymousIdentity [as 別名]
def signout():
    logout_user()
    for key in ("identity.name", "identity.auth_type"):
        session.pop(key, None)
    session.modified = True
    # Tell Flask-Principal the user is anonymous
    identity_changed.send(
        current_app._get_current_object(), identity=AnonymousIdentity()
    )
    return jsonify({"logged_in": False}) 
開發者ID:Flowminder,項目名稱:FlowKit,代碼行數:12,代碼來源:login.py


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