
    Oh                     Z    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	 Zy)
    )User)
exceptionsN)settings)Response)status   )AppUserc                    | j                   j                  d      }|st        d      	 |}t        j                  |t
        j                  dg      }t        j                  j                  |d         }|t        j                  d	      |j                  st        j                  d
      t        |j                        S # t        j                  $ r t        j                  d      t        $ r t        j                  d      w xY w)NAuthorizationzAuthentication failedHS256)
algorithmszaccess_token expiredzToken prefix missinguser_id)idzUser not foundzuser is inactive)headersget	Exceptionjwtdecoder   
SECRET_KEYExpiredSignatureErrorr   AuthenticationFailed
IndexErrorr	   objectsr   strr   )requestauthorization_headeraccess_tokenpayloaduserIDs        @/var/www/html/Kila-kolis-project/Kolis/userapi/authentication.pyauthenticatedr!   	   s    ++O<)**@%,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(   