o
    &zh                     @   s   d dl mZmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZmZ d dlmZmZ 								d		dddZdd Zdd Zd	S )    )PermissionDeniedValidationError)HttpResponseRedirect)app_settings)ImmediateHttpResponseReauthenticationRequiredSignupClosedException)httpkit)AuthenticationStatus)flowsstatekit)	AuthErrorAuthProcessNreturnc           
      C   s   d}|r| d}|du r| d}|rt| |}d|i}|dur3| d}| d}	|d |d< n
tj}d}	tj|d< |sAdS |	sKt| d	pJd
}	t	|	|}	t
t|	)zW
    Called at a time when it is not clear whether or not this is a headless flow.
    Nstatestate_iderrorheadlessnextprocesserror_processsocialaccount_login_error/)getr   unstash_stateallauth_settingsHEADLESS_ONLYr   LOGINr	   get_frontend_urladd_query_paramsr   r   )
requestproviderr   	exceptionextra_contextr   r   paramsr   next_url r&   b/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/headless/socialaccount/internal.pyon_authentication_error   s*   




r(   c                 C   s   t jj| |ddS )NTraises)r   logincomplete_login)r    socialloginr&   r&   r'   complete_token_login3   s   r.   c              
   C   s   d}zt jj| |dd W n3 ty   d}Y n> ty"   d}Y n4 ty,   d}Y n* ty@ } z	|j}W Y d}~nd}~ww t| }t	|j
 |j |  grVtj}|jd }|rit|||jd d	}t|S )
z0
    Called when `sociallogin.is_headless`.
    NTr)   reauthentication_requiredsignup_closedpermission_deniedr   r   )r   r   )r   r+   r,   r   r   r   r   coder
   allis_authenticatedhas_pending_signupget_pending_stager   UNKNOWNr   r	   r   r   )r    r-   r   estatusr%   r&   r&   r'   r,   7   s8   
r,   )NNNN)r   N)django.core.exceptionsr   r   django.httpr   allauthr   r   allauth.core.exceptionsr   r   r   allauth.core.internalr	   !allauth.headless.internal.authkitr
   allauth.socialaccount.internalr   r   .allauth.socialaccount.providers.base.constantsr   r   r(   r.   r,   r&   r&   r&   r'   <module>   s"    
#