o
    h                     @   sJ  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 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 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)reverse)	urlencode)app_settings)get_authentication_records)record_authentication)ReauthenticationRequired)deserialize_requestserialize_request)script_aware_resolve)import_callableaccount_reauthentication_staterequestreturnc                 C   s   t | | jddd d S )NpasswordT)methodreauthenticated)r   userr    r   f/var/www/html/pos/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)r   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=   rA   )
is_authenticatedhas_usable_passwordappendallauth_settingsMFA_ENABLEDallauth.mfa.modelsr?   allauth.mfa.utilsr@   Type)r   retentryr?   r@   rA   typr   r   r   r8   Y   s$   


r8   )*r9   typingr   r   r   django.contrib.authr   django.httpr   r   django.urlsr   django.utils.httpr	   allauthr
   rF   allauth.accountallauth.account.authenticationr   $allauth.account.internal.flows.loginr   allauth.core.exceptionsr   allauth.core.internal.httpkitr   r   allauth.core.internal.urlkitr   allauth.utilsr   r!   r   dictstrr"   r(   r2   r4   boolr3   r8   r   r   r   r   <module>   s<    

	