o
    Ti7                     @   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   ^/var/www/html/evchargy.com/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)Zraise_exceptionr   )r   )
Zget_serializerr   Zis_validr   r
   argsr   Zvalidated_datar   ZHTTP_200_OK)r   r   r   kwargs
serializerer   r   r   post(   s   zTokenViewBase.post)__name__
__module____qualname__Zpermission_classesZ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   Z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%   r)   r   ZTOKEN_REFRESH_SERIALIZERr   r   r   r   r   r+   ?   r*   r+   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%   r)   r   ZSLIDING_TOKEN_OBTAIN_SERIALIZERr   r   r   r   r   r,   K   r*   r,   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%   r)   r   Z SLIDING_TOKEN_REFRESH_SERIALIZERr   r   r   r   r   r-   W   r*   r-   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%   r)   r   ZTOKEN_VERIFY_SERIALIZERr   r   r   r   r   r.   c   r*   r.   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%   r)   r   ZTOKEN_BLACKLIST_SERIALIZERr   r   r   r   r   r/   o   r*   r/   N)!Zdjango.utils.module_loadingr   Zrest_frameworkr   r   Zrest_framework.requestr   Zrest_framework.responser   Zrest_framework.serializersr   Zauthenticationr	   
exceptionsr
   r   settingsr   ZGenericAPIViewr   r(   Zas_viewZtoken_obtain_pairr+   Ztoken_refreshr,   Ztoken_obtain_slidingr-   Ztoken_refresh_slidingr.   Ztoken_verifyr/   Ztoken_blacklistr   r   r   r   <module>   s*    '						