swag-shop/app/jwt_utils.py
2024-03-05 16:02:13 +01:00

16 lines
460 B
Python

from app.extensions import jwt_redis_blocklist
from flask_jwt_extended import create_access_token
from flask_jwt_extended import get_jwt
from flask_jwt_extended import jwt_required
from flask_jwt_extended import JWTManager
@jwt.token_in_blocklist_loader
def check_if_token_is_revoked(jwt_header, jwt_payload: dict) -> bool:
jti = jwt_payload["jti"]
token_in_redis = jwt_redis_blocklist.get(jti)
print(token_in_redis)
return token_in_redis is not None