Python flask_principal.AnonymousIdentity() Examples
The following are 11
code examples of flask_principal.AnonymousIdentity().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask_principal
, or try the search function
.
Example #1
Source File: views.py From incepiton-mysql with MIT License | 5 votes |
def logout(): logout_user() identity_changed.send(current_app._get_current_object(), identity=AnonymousIdentity()) return redirect(url_for('.login'))
Example #2
Source File: utils.py From flask-security with MIT License | 5 votes |
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()
Example #3
Source File: auth.py From flaskapp with MIT License | 5 votes |
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'))
Example #4
Source File: __init__.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
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
Example #5
Source File: cloud.py From AstroBox with GNU Affero General Public License v3.0 | 5 votes |
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()
Example #6
Source File: security_service.py From flask-unchained with MIT License | 5 votes |
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())
Example #7
Source File: user.py From quay with Apache License 2.0 | 5 votes |
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}
Example #8
Source File: auth.py From knowledge-repo with Apache License 2.0 | 5 votes |
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'))
Example #9
Source File: models.py From maple-bbs with GNU General Public License v3.0 | 5 votes |
def logout(self): logout_user() identity_changed.send( current_app._get_current_object(), identity=AnonymousIdentity())
Example #10
Source File: views.py From gitmark with GNU General Public License v2.0 | 5 votes |
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'))
Example #11
Source File: login.py From FlowKit with Mozilla Public License 2.0 | 5 votes |
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})