
    gN                         d dl mZ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  G d	 d
e      Z G d de      Z G d de      Z G d de      Zy)    )OptionalType)classonlymethod)
LoginStageLoginStageController)ReauthenticationRequired)response)Client)
decorators)RESTViewc                   2     e Zd ZdZed        Z fdZ xZS )APIViewNc                      | j                   di |}|d   t        j                  k(  rt        j                  |      }|S t        j
                  |      }|S )Nclient )as_viewr
   APPr   app_viewbrowser_view)cls
initkwargs	view_funcs      X/var/www/django_project/virt/lib/python3.12/site-packages/allauth/headless/base/views.pyas_api_viewzAPIView.as_api_view   sV    CKK-*-	h6::-"++I6I  #//	:I    c                     	 t        |   |g|i |S # t        $ r" t        j                  | j
                        cY S w xY wN)superdispatchr   r	   ReauthenticationResponserequestselfr!   argskwargs	__class__s       r   r   zAPIView.dispatch   sI    	C7#G=d=f==' 	C44T\\BB	Cs    (A A)__name__
__module____qualname__r   r   r   r   __classcell__r&   s   @r   r   r      s&    F C Cr   r   c                   F     e Zd ZU dZeee      ed<    fdZd Z	d Z
 xZS )AuthenticationStageAPIViewNstage_classc                     t        j                  || j                  j                        | _        | j                  st        j                  |      S t        |    |g|i |S r   )	r   enterr.   keystager	   UnauthorizedResponser   handler"   s       r   r4   z!AuthenticationStageAPIView.handle#   sT    )//9I9I9M9MN
zz0099w~g7777r   c                 @    t        j                  | j                        S r   )r	   r3   r!   r#   s    r   respond_stage_errorz.AuthenticationStageAPIView.respond_stage_error)   s    ,,T\\::r   c                 t    | j                   j                          t        j                  | j                        S r   )r2   exitr	   AuthenticationResponser!   r6   s    r   respond_next_stagez-AuthenticationStageAPIView.respond_next_stage,   s%    

..t||<<r   )r'   r(   r)   r.   r   r   r   __annotations__r4   r7   r;   r*   r+   s   @r   r-   r-       s&    .2K$z*+28;=r   r-   c                        e Zd Z fdZ xZS )AuthenticatedAPIViewc                     |j                   j                  st        j                  |      S t	        |   |g|i |S r   )useris_authenticatedr	   r:   r   r   r"   s       r   r   zAuthenticatedAPIView.dispatch2   s;    ||,,227;;w9$9&99r   )r'   r(   r)   r   r*   r+   s   @r   r>   r>   1   s    : :r   r>   c                       e Zd Zd Zy)
ConfigViewc                 ,    t        j                  |      S )z
        The frontend queries (GET) this endpoint, expecting to receive
        either a 401 if no user is authenticated, or user information.
        )r	   ConfigResponse)r#   r!   r$   r%   s       r   getzConfigView.get9   s    
 &&w//r   N)r'   r(   r)   rF   r   r   r   rC   rC   8   s    0r   rC   N)typingr   r   django.utils.decoratorsr   allauth.account.stagesr   r   allauth.core.exceptionsr   allauth.headless.baser	   allauth.headless.constantsr
   allauth.headless.internalr   'allauth.headless.internal.restkit.viewsr   r   r-   r>   rC   r   r   r   <module>rO      sO    ! 3 C < * - 0 <Ch C&= =":7 :0 0r   