Exemple #1
0
def change_jwt_unrevoke_state(jti):
    username = get_jwt_identity()
    try:
        token_data = get_stored_token(jti)
        if token_data['token']['identity'] != username:
            raise KeyError
        unrevoke_token(jti)
        return jsonify({"msg": "Token successfully unrevoked"}), 200
    except KeyError:
        return jsonify({'msg': 'Token not found'}), 404
Exemple #2
0
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"})
Exemple #3
0
 def unrevoke(jti):
     try:
         unrevoke_token(jti)
         return jsonify({"msg": "Token unrevoked"})
     except KeyError:
         return jsonify({"msg": "Token not found"}), 404