o
    "4g                     @   s   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 dlmZ d dlmZ d dlmZ d d	lmZ d
d Zdd Zdd Zdd Zdd Zdd Zdd ZdS )    )ValidationError)app_settings)get_adapter)assess_unique_email)complete_signupprevent_enumeration)user_username)SignupClosedException)headed_redirect_response)SocialLoginc                 C   s   | j d}|rt|S d S Nsocialaccount_sociallogin)sessiongetr   deserialize)requestdata r   t/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/socialaccount/internal/flows/signup.pyget_pending_signup   s   
r   c                 C   s   |  | jd< tdS )Nr   socialaccount_signup)	serializer   r
   r   socialloginr   r   r   redirect_to_signup   s   r   c                 C   s   | j dd  d S r   )r   pop)r   r   r   r   clear_pending_signup   s   r   c                 C   s(   t |  || \}}|st| |}|S )N)r   try_savecomplete_social_signup)r   r   formuserrespr   r   r   signup_by_form!   s
   
r"   c                 C   s   t  | |}|sdS d }|jr|jd j}|r>t|}|du r%	 |d fS |du r/d}|d fS |d u s5J t| |}d|fS tjrCd}|d fS )N)FNr   TF)r   is_auto_signup_allowedemail_addressesemailr   r   r   EMAIL_REQUIRED)r   r   auto_signupr%   
assessmentr!   r   r   r   process_auto_signup)   s(   
r)   c                 C   s   t  | |s
t t| |\}}|r|S |st| |}|S tjr?t|j}z	t	| 
| W n ty>   t|jd Y nw t  j| |d d t| |}|S )N )r   )r   is_open_for_signupr	   r)   r   account_settingsUSER_MODEL_USERNAME_FIELDr   r    get_account_adapterclean_usernamer   	save_userr   )r   r   r'   r!   usernamer   r   r   process_signupQ   s$   


r2   c                 C   s    t | |jtj|| d|idS )Nr   )r    email_verificationredirect_urlsignal_kwargs)r   r    r   EMAIL_VERIFICATIONget_redirect_urlr   r   r   r   r   k   s   r   N)django.formsr   allauth.accountr   r,   allauth.account.adapterr   r.   +allauth.account.internal.flows.manage_emailr   %allauth.account.internal.flows.signupr   r   allauth.account.utilsr   allauth.core.exceptionsr	   allauth.core.internal.httpkitr
   allauth.socialaccountallauth.socialaccount.adapterallauth.socialaccount.modelsr   r   r   r   r"   r)   r2   r   r   r   r   r   <module>   s$    (