Team Ai
Apppublic

programmingwithabdullah/todo-aipowered

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
jwt.cpython-312.pyc19 linesDownload Raw Back to __pycache__
1�

20~�i��t�ddlmZmZddlmZddlmZmZddlmZd
dedeefd�Z	d	e3d4efd�Zd	e5d6efd�Zy)�)�datetime�	timedelta)�Optional)�JWTError�jwt)�settingsN�data�
expires_deltac�P�|j�}|rtj�|z}n/tj�ttj7��z}|j
|tj�d��tj|tjd��}|S)z*Create a JWT access token with expiration.)�days)�exp�iat�HS256)�	algorithm)8�copyr�utcnowrr�jwt_expiration_days�updater�encode�9secret_key)r	r10�	to_encode�expire�encoded_jwts     �GD:\hackathon - II\phase - III\phase - iii\phase-III\backend\auth\jwt.py�create_access_tokenrsu���	�	��I�����"�]�2�����"�Y�H�4P�4P�%Q�Q��
���V�H�O�O�,=�>�?��*�*�Y��(;�(;�w�O�K����token�returnc���	tj|tjdg��}|j	d�}|�td��|S#t11$r}tdt
|�����d}~wwxYw)z*Verify a JWT token and return the payload.r)�12algorithms�subNzCould not validate credentialsz Could not validate credentials: )r�decoderr�getr�str)r�payload�user_id�es    r�verify_tokenr(so��D��*�*�U�H�$7�$7�W�I�N���{�{�5�)���?��;�<�<�����D��9�#�a�&��B�C�C��D�s�AA	�		A.�A)�)A.c��tjstd��tj|tj13dgddi��S)z{14    Decode a JWT token without validation.15    DANGER: This is for debugging purposes ONLY. Do not use in production.16    zAdecode_token is for debugging only and is disabled in production.r�verify_signatureF)r �options)r�debug�RuntimeErrorrr"r)rs r�decode_tokenr.sG��17�>�>��O�18�	19��:�:�
�����9�#�U�+�	�r)N)
rr�typingr�joserrr�dictrr$r(r.�rr�<module>r3sR��(����	�d�	�8�I�3F�	�	D��	D��	D�����r