o
    "4gc                     @   sB  d dl Z d dlmZmZmZ d dlmZ d dlmZ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 d d
lmZ d dlmZmZ d dlmZ dZdeddfddZdede de!de	fddZ"dede!de	fddZ#dedee	 fddZ$deddfddZ%dede&fddZ'dee fdd Z(dS )!    N)DictListOptional)REDIRECT_FIELD_NAME)HttpRequestHttpResponseRedirect)resolvereverse)	urlencode)app_settings)get_authentication_recordsrecord_authentication)ReauthenticationRequired)deserialize_requestserialize_request)import_callableaccount_reauthentication_staterequestreturnc                 C   s   t | ddd d S )NpasswordT)methodreauthenticatedr   r    r   x/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/account/internal/flows/reauthentication.pyreauthenticate_by_password   s   r   statecallbackc                 C   s   ||d| j t< ttdS )N)r   r   account_reauthenticate)sessionSTATE_SESSION_KEYr   r	   )r   r   r   r   r   r   stash_and_reauthenticate   s   r"   redirect_toc                 C   s<   |   }| jdkrdt| i| jt< t|d tt|i S )NPOSTr   ?)get_full_pathr   r   r    r!   r   r
   r   )r   r#   pathr   r   r   suspend_request&   s   
r(   c                 C   s   ddl m} | jtd }|r d|v r t|d }|| |d S || t}|s)d S |rNd|v rNt|d | }|j|krNt	|j}|j
|g|jR i |jS t|S )Nr   )get_next_redirect_urlr   r   r   )allauth.account.utilsr)   r    popr!   r   r   r   r'   r   funcargskwargsr   )r   r)   r   r   urlsuspended_requestresolvedr   r   r   resume_request/   s   


r2   c                 C   s   t | st d S )N)did_recently_authenticater   r   r   r   r   "raise_if_reauthentication_requiredB   s   r4   c                 C   sH   | j jrdS t| j sdS t| }|sdS |d d }t | tjk S )NFTat)useris_anonymousget_reauthentication_flowsr   timer   REAUTHENTICATION_TIMEOUT)r   methodsauthenticated_atr   r   r   r3   G   s   
r3   c                 C   s   g }| j s|S |  rddi}|| tjrAddlm} ddlm} g }|j	D ]}|| |gdr6|| q(|rA|d|d |S )	Nidreauthenticater   )Authenticator)is_mfa_enabled)typesmfa_reauthenticate)r>   rB   )
is_authenticatedhas_usable_passwordappendallauth_settingsMFA_ENABLEDallauth.mfa.modelsr@   allauth.mfa.utilsrA   Type)r7   retentryr@   rA   rB   typr   r   r   r9   Y   s$   


r9   ))r:   typingr   r   r   django.contrib.authr   django.httpr   r   django.urlsr   r	   django.utils.httpr
   allauthr   rG   allauth.accountallauth.account.authenticationr   $allauth.account.internal.flows.loginr   allauth.core.exceptionsr   allauth.core.internal.httpkitr   r   allauth.utilsr   r!   r   dictstrr"   r(   r2   r4   boolr3   r9   r   r   r   r   <module>   s:    

	