本文整理汇总了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'))
示例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()
示例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'))
示例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
示例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()
示例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())
示例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}
示例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'))
示例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())
示例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'))
示例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})