def change_jwt_revoke_state(jti): email = get_jwt_identity() try: token_data = get_stored_token(jti) if token_data['token']['identity'] != email: raise KeyError revoke_token(jti) return jsonify({"msg": "Token successfully revoked"}), 200 except KeyError: return jsonify({'msg': 'Token not found'}), 404
def logout(): try: current_token = get_raw_jwt() jti = current_token['jti'] revoke_token(jti) return makeResponse(payload={}, message="Logged out") except KeyError as e: return makeResponse(error=e) except Exception as e: return makeResponse(error=e)
def change_jwt_revoke_state(jti): # TODO you should put some extra protection on this, so a user can only # modify their tokens revoke = request.json.get('revoke', None) if revoke is None: return jsonify({'msg': "Missing json argument: 'revoke'"}), 422 if not isinstance(revoke, bool): return jsonify({'msg': "revoke' must be a boolean"}), 422 if revoke: revoke_token(jti) return jsonify({"msg": "Token successfully revoked"}) else: unrevoke_token(jti) return jsonify({"msg": "Token successfully unrevoked"})
def _revoke_current_token(): current_token = get_raw_jwt() jti = current_token['jti'] revoke_token(jti)
def revoke(jti): try: revoke_token(jti) return jsonify({"msg": "Token revoked"}) except KeyError: return jsonify({"msg": "Token not found"}), 404
def logout(): jti = get_raw_jwt()['jti'] revoke_token(jti) ret = {"msg": "Successfully logged out"} return jsonify(ret), 200