
    rh                        d dl mZ d dlmZ d dlmZm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mZ dd
lmZ  G d dej(                        Z G d de      Zej/                         Z G d de      Zej/                         Z G d de      Zej/                         Z G d de      Zej/                         Z G d de      Zej/                         Z  G d de      Z!e!j/                         Z"y)    )Optional)import_string)genericsstatus)Request)Response)BaseSerializer   )AUTH_HEADER_TYPES)InvalidToken
TokenError)api_settingsc                   j    e Zd ZU dZdZdZeee      e	d<   dZ
dZdee   fdZdedefd	Zdedefd
Zy)TokenViewBase Nserializer_class apireturnc                     | j                   r| j                   S 	 t        | j                        S # t        $ r!}d| j                   d}t        |      |d}~ww xY w)ze
        If serializer_class is set, use it directly. Otherwise get the class from settings.
        zCould not import serializer ''N)r   r   _serializer_classImportError)selfemsgs      q/var/www/html/ai-insurance-compliance-backend/venv/lib/python3.12/site-packages/rest_framework_simplejwt/views.pyget_serializer_classz"TokenViewBase.get_serializer_class   sa    
   (((	* !7!788 	*1$2H2H1IKCc")	*s   / 	AAArequestc                 H    dj                  t        d   | j                        S )Nz{} realm="{}"r   )formatr   www_authenticate_realm)r   r   s     r   get_authenticate_headerz%TokenViewBase.get_authenticate_header$   s&    %%a ''
 	
    c                     | j                  |j                        }	 |j                  d       t        |j                  t        j                        S # t        $ r}t	        |j
                  d         |d }~ww xY w)N)dataT)raise_exceptionr   )r   )
get_serializerr&   is_validr   r   argsr   validated_datar   HTTP_200_OK)r   r   r*   kwargs
serializerr   s         r   postzTokenViewBase.post*   sq    ((gll(;
	15 
11&:L:LMM  	1qvvay)q0	1s   A 	A<A77A<)__name__
__module____qualname__permission_classesauthentication_classesr   r   typer	   __annotations__r   r"   r   r   strr#   r   r/   r   r$   r   r   r      si    7;htN34;"*d>&: *
w 
3 
NG N Nr$   r   c                   (    e Zd ZdZej
                  Zy)TokenObtainPairViewz
    Takes a set of user credentials and returns an access and refresh JSON web
    token pair to prove the authentication of those credentials.
    N)r0   r1   r2   __doc__r   TOKEN_OBTAIN_SERIALIZERr   r   r$   r   r9   r9   5       
 %<<r$   r9   c                   (    e Zd ZdZej
                  Zy)TokenRefreshViewzz
    Takes a refresh type JSON web token and returns an access type JSON web
    token if the refresh token is valid.
    N)r0   r1   r2   r:   r   TOKEN_REFRESH_SERIALIZERr   r   r$   r   r>   r>   A   s    
 %==r$   r>   c                   (    e Zd ZdZej
                  Zy)TokenObtainSlidingViewz
    Takes a set of user credentials and returns a sliding JSON web token to
    prove the authentication of those credentials.
    N)r0   r1   r2   r:   r   SLIDING_TOKEN_OBTAIN_SERIALIZERr   r   r$   r   rA   rA   M   s    
 %DDr$   rA   c                   (    e Zd ZdZej
                  Zy)TokenRefreshSlidingViewz
    Takes a sliding JSON web token and returns a new, refreshed version if the
    token's refresh period has not expired.
    N)r0   r1   r2   r:   r    SLIDING_TOKEN_REFRESH_SERIALIZERr   r   r$   r   rD   rD   Y   s    
 %EEr$   rD   c                   (    e Zd ZdZej
                  Zy)TokenVerifyViewz
    Takes a token and indicates if it is valid.  This view provides no
    information about a token's fitness for a particular use.
    N)r0   r1   r2   r:   r   TOKEN_VERIFY_SERIALIZERr   r   r$   r   rG   rG   e   r<   r$   rG   c                   (    e Zd ZdZej
                  Zy)TokenBlacklistViewz~
    Takes a token and blacklists it. Must be used with the
    `rest_framework_simplejwt.token_blacklist` app installed.
    N)r0   r1   r2   r:   r   TOKEN_BLACKLIST_SERIALIZERr   r   r$   r   rJ   rJ   q   s    
 %??r$   rJ   N)#typingr   django.utils.module_loadingr   rest_frameworkr   r   rest_framework.requestr   rest_framework.responser   rest_framework.serializersr	   authenticationr   
exceptionsr   r   settingsr   GenericAPIViewr   r9   as_viewtoken_obtain_pairr>   token_refreshrA   token_obtain_slidingrD   token_refresh_slidingrG   token_verifyrJ   token_blacklistr   r$   r   <module>r]      s     5 + * , 5 - 0 "$NH++ $NN=- = (//1 >} > !((*E] E .557 Fm F 0779 =m = &&(@ @ %,,.r$   