o
    Wg                     @   s\   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
 ZdS )    )User)
exceptionsN)settings)Response)status   )EndUserc                 C   s   | j d}td| |stdz|}td| tj|tjdgd}td| W n  tjy:   td t	
d	 tyI   td
 t	
dw tjj|d d}|d u r\t	
dt|jS )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   userID r!   ;/var/www/html/lionshead-backend/panel_api/authentication.pyauthenticated	   s,   






r#   )django.contrib.auth.modelsr   rest_frameworkr   r   django.confr   rest_framework.responser   r   modelsr   r#   r!   r!   r!   r"   <module>   s    