
    fF                         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 d dlmZ d d
lmZmZ d Zd Zd Zd Zd Zy)    )messages)PermissionDeniedValidationError)HttpResponseRedirect)app_settings)get_adapter)flows)EmailAddress)ReauthenticationRequired)signals)SocialAccountSocialLoginc                 l   t         j                  j                  |j                        }|j	                  |j
                        j                          }t               }|rt        j                  r|j                  d      |j                  j                         s|j                  d      t        j                  t        j                  j                   k(  rJt"        j                  j                  |j                  d      j                         s|j                  d      |j%                  ||       y)	z[
    Validate whether or not the socialaccount account can be
    safely disconnected.
    )user_id)pkdisconnect_lastno_passwordT)userverifiedno_verified_emailN)r   objectsfilterr   excluder   existsr   allauth_settingsSOCIALACCOUNT_ONLYvalidation_errorr   has_usable_passwordaccount_settingsEMAIL_VERIFICATIONEmailVerificationMethod	MANDATORYr
   validate_disconnect)requestaccountaccountsis_lastadapters        g/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/socialaccount/internal/flows/connect.pyr#   r#      s    
 $$++GOO+DH""gjj"188::GmG..**+<==||//1**=99 //77AAB  ''..\\D / fh ../BCC2    c                    t         j                  rt        j                  j	                  |        t               j                  | t        j                  d       |j                         }|j                          t        j                  j                  t        | |       t               j!                  d| j"                  ||d       y )Nz/socialaccount/messages/account_disconnected.txt)senderr$   socialaccountz(socialaccount/email/account_disconnected)r%   provider)context)r   REAUTHENTICATION_REQUIREDr	   reauthentication"raise_if_reauthentication_requiredget_account_adapteradd_messager   INFOget_providerdeleter   social_account_removedsendr   r   send_notification_mailr   )r$   r%   r.   s      r)   
disconnectr;   *   s    11AA'J%%9
 ##%HNN""''gW (  M((2 
 ) r*   c                 D    t        j                  |      }t        | |      S )N)r   deserializeconnect)r$   serialized_statesociallogins      r)   resume_connectrA   B   s     ))*:;K7K((r*   c                 B   	 t        | |      \  }}}|rt        j                  nt        j                  }t               j                  | |j                        }|j                  |       xs |}t!        |       j#                  | ||||d       t        |      S # t        $ r2 t               j                  | |j                        }t        |      cY S t        $ r2 t        j                  j                  | |j                         d      cY S t        $ r
 d\  }}}Y w xY w)Nz;allauth.socialaccount.internal.flows.connect.resume_connect)FNz2socialaccount/messages/account_connected_other.txt)r@   action)message_context)
do_connectr   r   get_connect_redirect_urlr%   r   r   r	   r1   stash_and_reauthenticate	serializer   r   r5   ERRORget_redirect_urlr3   r4   )	r$   r@   okrC   messageconnect_redirect_urlleveldefault_nextnext_urls	            r)   r>   r>   G   s   
(+>FG(  HMMX^^E=99';CVCVWL++G4DH ,,(3vF	 -   ))9  :  +}EE[(( 
 $$899# 
%%>>!!#I
 	

  

FG
s   B 8D7DDDc                    | j                   j                  r
t               t        j                  rt
        j                  j                  |        d}d }d}|j                  rv|j                   | j                   k7  rt               j                  d      |j                  j                  j                  sd}d}n=d}|j                  | | j                          nd}|j                  | | j                          |||fS )Nz,socialaccount/messages/account_connected.txtTconnected_otherupdatedz4socialaccount/messages/account_connected_updated.txtadded)r   is_anonymousr   r   r0   r	   r1   r2   is_existingr   r   r%   _stateaddingr>   )r$   r@   rL   rC   rK   s        r)   rE   rE   i   s    ||    11AA'J<GF	Bw||+
 -001BCC$$++22FLGF6 GW\\2vwr*   N) django.contribr   django.core.exceptionsr   r   django.httpr   allauthr   r   allauth.accountr   allauth.account.adapterr   r3   allauth.account.internalr	   allauth.account.modelsr
   allauth.core.exceptionsr   allauth.socialaccountr   allauth.socialaccount.adapterallauth.socialaccount.modelsr   r   r#   r;   rA   r>   rE    r*   r)   <module>rf      sC    # D , 4 < F * / < ) 5 C340)
*Dr*   