a
    ̸d}	                     @   sP   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 Z
dS )	    )User)
exceptionsN)settings)Response)statusc                 C   s   | j d}td| |s"tdz0|}td| tj|tjdgd}td| W nH tjyx   td t	
d	Y n$ ty   td
 t	
dY n0 tjj|d d}|d u rt	
d|jst	
dt|jS )NAuthorizationauthorization_headerzAuthentication failedaccess_tokenHS256)
algorithmspayloadZexcepzaccess_token expiredZexcep2zToken prefix missinguser_id)idzUser not foundzuser is inactive)headersgetprint	Exceptionjwtdecoder   
SECRET_KEYZExpiredSignatureErrorr   AuthenticationFailed
IndexErrorr   objects	is_activestrr   )requestr   r	   r   ZuserID r   :/var/www/html/Sam_Eipo/Eipo/customer_api/authentication.pyauthenticated   s.    




r   )django.contrib.auth.modelsr   rest_frameworkr   r   django.confr   rest_framework.responser   r   r   r   r   r   r   <module>   s   