generateur_v3/backend/api/services/jwt.py
2022-09-16 21:50:55 +02:00

16 lines
561 B
Python

import config
def revoke_access(decrypted_token):
if decrypted_token['type'] == 'access':
jti= decrypted_token['jti']
config.redis_conn.setex(jti, config.settings.access_expires, 'true')
return {"detail": "Access token has been revoke"}
raise "Access token required"
def revoke_refresh(decrypted_token):
if decrypted_token['type'] == 'refresh':
jti= decrypted_token['jti']
config.redis_conn.setex(jti, config.settings.refresh_expires, 'true')
return {"detail": "Refresh token has been revoke"}
raise "Refresh token required"