
    ^h                     Z    S SK Jr  S SKJr  S SKrS SKJr  S SKJr  S SKJ	r	  SSK
Jr  S	 rg)
    )User)
exceptionsN)settings)Response)status   )EndUserc                 V   U R                   R                  S5      n[        SU5        U(       d  [        S5      e Un[        SU5        [        R
                  " U[        R                  S/S9n[        SU5        [        R                  R                  US   S9nUc  [        R                  " S5      e[        UR                  5      $ ! [        R                   a"    [        S5        [        R                  " S	5      e[         a"    [        S
5        [        R                  " S5      ef = f)NAuthorizationauthorization_headerzAuthentication failedaccess_tokenHS256)
algorithmspayloadexcepzaccess_token expiredexcep2zToken prefix missinguser_id)idzUser not found)headersgetprint	Exceptionjwtdecoder   
SECRET_KEYExpiredSignatureErrorr   AuthenticationFailed
IndexErrorr	   objectsstrr   )requestr   r   r   userIDs        5/var/www/html/tms-backend/panel_api/authentication.pyauthenticatedr$   	   s   ++O<23)**@%,|$JJ$$'<'	' //

!3

4
N''(899FII 	!! @.''(>?? @/''(>??@s   ?C A D()django.contrib.auth.modelsr   rest_frameworkr   r   django.confr   rest_framework.responser   r   modelsr	   r$        r#   <module>r,      s    + % 
   , ! r+   