swag-shop/app/jwt_utils.py

14 lines
324 B
Python
Raw Permalink Normal View History

2024-03-05 16:01:26 +01:00
from app.extensions import jwt_redis_blocklist
from . import jwt_manager
2024-03-05 16:01:26 +01:00
from app import app
@jwt_manager.token_in_blocklist_loader
2024-03-05 16:01:26 +01:00
def check_if_token_is_revoked(jwt_header, jwt_payload: dict) -> bool:
jti = jwt_payload["jti"]
token_in_redis = jwt_redis_blocklist.get(jti)
2024-03-05 16:01:26 +01:00
return token_in_redis is not None