generateur_v3/backend/api/services/jwt.py

16 lines
561 B
Python
Raw Normal View History

2022-09-16 21:50:55 +02:00
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"