Beispiel #1
0
def logout():
    try:
        current_token = get_raw_jwt()
        jti = current_token["jti"]
        auth_service.revoke_tokens(app, jti)
    except:
        pass
Beispiel #2
0
    def get(self):
        try:
            current_token = get_raw_jwt()
            jti = current_token['jti']
            auth_service.revoke_tokens(app, jti)
            identity_changed.send(current_app._get_current_object(),
                                  identity=AnonymousIdentity())
        except KeyError:
            return {"Access token not found."}, 500

        logout_data = {"logout": True}

        if is_from_browser(request.user_agent):
            response = jsonify(logout_data)
            unset_jwt_cookies(response)
            return response
        else:
            return logout_data