
    )JfL%                     (   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 d	lmZmZmZ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"m#Z# d Z$d Z%d Z&d Z'e"j(        ddfdZ)d Z*d Z+d Z,d Z-d Z.d Z/d Z0dS )    )messages)ValidationError)HttpResponseRedirect)render)reverse)app_settingsauthentication)get_adapter)reauthenticate_then_callback)assess_unique_emailcomplete_signupperform_loginuser_display
user_emailuser_username)ImmediateHttpResponse)r   signals)SocialLogin)	AuthErrorAuthProcessc                 X   t                                          | |          }|sdS t          |j                  }|r]t	          |          }|du rnW|du rd}nP|J t          |           }|                    |           |                    | d           }d|fS t          j	        rd}|d fS )N)FNTF)
r
   is_auto_signup_allowedr   userr   get_account_adapter send_account_already_exists_mailrespond_email_verification_sentr   EMAIL_REQUIRED)requestsocialloginauto_signupemail
assessmentaccount_adapterresps          `/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/allauth/socialaccount/helpers.py_process_auto_signupr&      s    --66wLLK {{'((E (//
5    KK
 %%% 2'::O<<UCCC"BB7DQQD$;		$     c                 f   t          | |          \  }}|r|S |s;|                                | j        d<   t          d          }t	          |          }nt
          j        r]t          |j                  }	 t          |           
                    |           n%# t          $ r t          |j        d           Y nw xY wt                                          | |          st          | dt
          j        z             S t                                          | |d            t#          | |          }|S )Nsocialaccount_socialloginsocialaccount_signup zaccount/signup_closed.)form)r&   	serializesessionr   r   account_settingsUSER_MODEL_USERNAME_FIELDr   r   r   clean_usernamer   r
   is_open_for_signupr   TEMPLATE_EXTENSION	save_usercomplete_social_signup)r   r   r    r$   urlusernames         r%   _process_signupr8   A   sJ   ,WkBBK  <7B7L7L7N7N34,--#C(( 5 	4$[%566H4#G,,;;HEEEE" 4 4 4k.333334 }}//EE 	(+;+NN   	4@@@%g{;;Ks   6"B B;:B;c                 Z    t          j        | dfi |j        j        |j        j        d d S )Nsocialaccount)provideruid)r	   record_authenticationaccountr;   r<   r   r   s     r%   r=   r=   `   sO    (  $+4&*
 
    r'   c                 r    t          | |j        t          j        |                    |           d|i          S )Nr   )email_verificationredirect_urlsignal_kwargs)r   r   r   EMAIL_VERIFICATIONget_redirect_urlr?   s     r%   _login_social_accountrF   k   sA    ': 11'::$k2   r'   Nc                 d   	 |i }t                                          | ||||           n# t          $ r}|j        cY d }~S d }~ww xY w|t          j        k    rt          t          d                    S d|||di}|                    |           t          | dt          j        z   |          S )N)error	exceptionextra_contextsocialaccount_login_cancelled
auth_error)r;   coderI   z#socialaccount/authentication_error.)r
   on_authentication_errorr   responser   	CANCELLEDr   r   updater   r/   r3   )r   r;   rH   rI   rJ   econtexts          r%   render_authentication_errorrT   u   s     M--' 	. 	
 	
 	
 	
 !   z	####G,K$L$LMMM "
 
G NN=!!!-0@0SS  s   *- 
AAAAc                 J    t          j        |          }t          | |          S N)r   deserialize_add_social_account)r   serialized_stater   s      r%   resume_add_social_accountrZ      s#    )*:;;Kw444r'   c                    | j         j        r6t                                          | j                  }t          |          S t          j        rt          | fdd          }|r|S t          j
        }d}d }j        r$j         | j         k    rt          j        }d}n"d}d}nd}                    | | j                    | j         j        sJ t                                          | j                  }                    |           p|}t!          |                               | |||d	           t          |          S )
Nc                 ,                                     S rV   )r-   r?   s    r%   <lambda>z%_add_social_account.<locals>.<lambda>   s    K1133 r'   z7allauth.socialaccount.helpers.resume_add_social_accountz,socialaccount/messages/account_connected.txtz2socialaccount/messages/account_connected_other.txtupdatedz4socialaccount/messages/account_connected_updated.txtadded)r   action)message_context)r   is_anonymousr
   get_connect_redirect_urlr>   r   r/   REAUTHENTICATION_REQUIREDr   r   INFOis_existingERRORconnectis_authenticatedrE   r   add_message)	r   r   connect_redirect_urlrO   levelmessager`   default_nextnext_urls	    `       r%   rX   rX      sw   |  :  +}}EE[( 
  
 $$89991 /3333E
 

  	OME<GF 3w|++
 NEJGG FLGG GW\222<((((==99';CVWWL++G44DH  ,,(3vFF	 -     )))r'   c                    |j         rJ |                                 	 t                                          | |           t          j                            t          | |           |j                            d          }|t          j
        k    rt          | |          S |t          j        k    rt          | |          S t          | |          S # t          $ r}|j        cY d }~S d }~ww xY w)N)senderr   r   process)rf   lookupr
   pre_social_loginr   sendr   stategetr   REDIRECT_social_login_redirectCONNECTrX   _complete_social_loginr   rO   )r   r   rr   rR   s       r%   complete_social_loginr|      s   &&&&&&w<<< %%[ 	& 	
 	
 	
 #''	22k***)';???+++&w<<<)';???    zs*   BC "C C 
C-C("C-(C-c                 N    |                     |           pd}t          |          S )N/)rE   r   )r   r   ro   s      r%   ry   ry      s(    ++G44;H)))r'   c                     | j         j        r"t          |                               |            |j        r!t          | |           t          | |          }nt          | |          }|S rV   )r   ri   r   logoutrf   r=   rF   r8   )r   r   rets      r%   r{   r{      sm    |$ 5G$$++G444 4g{333#G[99 g{33Jr'   c                 r    t          | |j        t          j        |                    |           d|i          S )Nr   )rC   )r   r   r   rD   rE   r?   s     r%   r5   r5      sA    '$$W--$k2   r'   c                 \    t           j        }|st          | j                  S  ||           S rV   )r   SOCIALACCOUNT_STRr   r   )r:   funcs     r%   socialaccount_user_displayr      s3    )D 0M.///4r'   )1django.contribr   django.formsr   django.httpr   django.shortcutsr   django.urlsr   allauth.accountr   r/   r	   allauth.account.adapterr
   r    allauth.account.reauthenticationr   allauth.account.utilsr   r   r   r   r   r   allauth.core.exceptionsr   allauth.socialaccountr   allauth.socialaccount.adapterallauth.socialaccount.modelsr   $allauth.socialaccount.providers.baser   r   r&   r8   r=   rF   UNKNOWNrT   rZ   rX   r|   ry   r{   r5   r    r'   r%   <module>r      s'   # # # # # # ( ( ( ( ( ( , , , , , , # # # # # #       L L L L L L L L F F F F F F I I I I I I                : 9 9 9 9 9 7 7 7 7 7 7 7 7 5 5 5 5 5 5 4 4 4 4 4 4 G G G G G G G G% % %P  >     
! ! ! !H5 5 5
-* -* -*`  &* * *

 
 
      r'   