o
    Ch                     @   s  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 dejZG dd deZe ZG dd deZe ZG dd deZe ZG dd deZe ZG dd deZe Z G dd deZ!e! Z"dS )    )Optional)import_string)genericsstatus)Request)Response)BaseSerializer   )AUTH_HEADER_TYPES)InvalidToken
TokenError)api_settingsc                   @   sh   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dZd	edefd
dZd	edefddZdS )TokenViewBase Nserializer_class apireturnc              
   C   sJ   | j r| j S zt| jW S  ty$ } zd| j d}t||d}~w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msgr   r   p/var/www/html/myvaluetrips/my_value_trip_new/venv/lib/python3.10/site-packages/rest_framework_simplejwt/views.pyget_serializer_class   s   
z"TokenViewBase.get_serializer_classrequestc                 C   s   d td | jS )Nz{} realm="{}"r   )formatr
   www_authenticate_realm)r   r   r   r   r   get_authenticate_header$   s   z%TokenViewBase.get_authenticate_headerc              
   O   sX   | j |jd}z|jdd W n ty# } zt|jd |d }~ww t|jtj	dS )N)dataT)raise_exceptionr   )r   )
get_serializerr    is_validr   r   argsr   validated_datar   HTTP_200_OK)r   r   r$   kwargs
serializerr   r   r   r   post*   s   zTokenViewBase.post)__name__
__module____qualname__permission_classesauthentication_classesr   r   typer   __annotations__r   r   r   r   strr   r   r)   r   r   r   r   r      s   
 r   c                   @      e Zd ZdZejZdS )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)r*   r+   r,   __doc__r   TOKEN_OBTAIN_SERIALIZERr   r   r   r   r   r3   5       
r3   c                   @   r2   )TokenRefreshViewzz
    Takes a refresh type JSON web token and returns an access type JSON web
    token if the refresh token is valid.
    N)r*   r+   r,   r4   r   TOKEN_REFRESH_SERIALIZERr   r   r   r   r   r7   A   r6   r7   c                   @   r2   )TokenObtainSlidingViewz
    Takes a set of user credentials and returns a sliding JSON web token to
    prove the authentication of those credentials.
    N)r*   r+   r,   r4   r   SLIDING_TOKEN_OBTAIN_SERIALIZERr   r   r   r   r   r9   M   r6   r9   c                   @   r2   )TokenRefreshSlidingViewz
    Takes a sliding JSON web token and returns a new, refreshed version if the
    token's refresh period has not expired.
    N)r*   r+   r,   r4   r    SLIDING_TOKEN_REFRESH_SERIALIZERr   r   r   r   r   r;   Y   r6   r;   c                   @   r2   )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)r*   r+   r,   r4   r   TOKEN_VERIFY_SERIALIZERr   r   r   r   r   r=   e   r6   r=   c                   @   r2   )TokenBlacklistViewz~
    Takes a token and blacklists it. Must be used with the
    `rest_framework_simplejwt.token_blacklist` app installed.
    N)r*   r+   r,   r4   r   TOKEN_BLACKLIST_SERIALIZERr   r   r   r   r   r?   q   r6   r?   N)#typingr   django.utils.module_loadingr   rest_frameworkr   r   rest_framework.requestr   rest_framework.responser   rest_framework.serializersr   authenticationr
   
exceptionsr   r   settingsr   GenericAPIViewr   r3   as_viewtoken_obtain_pairr7   token_refreshr9   token_obtain_slidingr;   token_refresh_slidingr=   token_verifyr?   token_blacklistr   r   r   r   <module>   s,    '						