o
     e7                     @   s  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 )    )import_string)genericsstatus)Request)Response)
Serializer   )AUTH_HEADER_TYPES)InvalidToken
TokenError)api_settingsc                   @   sR   e Zd ZdZdZdZdZdZd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 apireturnc                 C   s:   | j r| j S zt| jW S  ty   d| j }t|w )ze
        If serializer_class is set, use it directly. Otherwise get the class from settings.
        z Could not import serializer '%s')serializer_classr   _serializer_classImportError)selfmsgr   r   Q/var/www/html/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   sV   | 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
serializerer   r   r   post(   s   zTokenViewBase.post)__name__
__module____qualname__permission_classesauthentication_classesr   r   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   r/   3       
r/   c                   @   r.   )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*   r0   r   TOKEN_REFRESH_SERIALIZERr   r   r   r   r   r3   ?   r2   r3   c                   @   r.   )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*   r0   r   SLIDING_TOKEN_OBTAIN_SERIALIZERr   r   r   r   r   r5   K   r2   r5   c                   @   r.   )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*   r0   r    SLIDING_TOKEN_REFRESH_SERIALIZERr   r   r   r   r   r7   W   r2   r7   c                   @   r.   )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*   r0   r   TOKEN_VERIFY_SERIALIZERr   r   r   r   r   r9   c   r2   r9   c                   @   r.   )TokenBlacklistViewz~
    Takes a token and blacklists it. Must be used with the
    `rest_framework_simplejwt.token_blacklist` app installed.
    N)r(   r)   r*   r0   r   TOKEN_BLACKLIST_SERIALIZERr   r   r   r   r   r;   o   r2   r;   N)!django.utils.module_loadingr   rest_frameworkr   r   rest_framework.requestr   rest_framework.responser   rest_framework.serializersr   authenticationr	   
exceptionsr
   r   settingsr   GenericAPIViewr   r/   as_viewtoken_obtain_pairr3   token_refreshr5   token_obtain_slidingr7   token_refresh_slidingr9   token_verifyr;   token_blacklistr   r   r   r   <module>   s*    '						