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