
    Nh                     f    d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dlm	Z	 ddl
mZ d d	lmZ d
 Zy)    )User)
exceptionsN)settings)Response)status   )EndUser)timezonec                 J   | j                   j                  d      }t        d|       |st        d      	 |}t        d|       t	        j
                  |t        j                  dg      }t        d|       t        j                  j                  |d         }|t        j                  d      t        |j                        S # t        j                  $ r! t        d       t        j                  d	      t        $ r! t        d
       t        j                  d      w xY w)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        6/var/www/html/aiagenthome/user_panel/authentication.pyauthenticatedr%      s   ++O<23)**@%,|$JJ$$'<'	' //

!3

4
N''(899FII 	!! @.''(>?? @/''(>??@s   AC AD")django.contrib.auth.modelsr   rest_frameworkr   r   django.confr   rest_framework.responser   r   modelsr	   django.utilsr
   r%        r$   <module>r.      s"    + % 
   , !  !r-   