
    qh\)                    F   S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJrJ	r	J
r
  SSKJr  SSKJr  SS	KJr  \R$                  " S
5      r\R$                  " S\R(                  5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      rg)zModels mixins for Social Auth    )annotationsN)abstractmethod)datetime	timedeltatimezone)Any)Association   )MissingBackendz[^\x00-\x7F]+z[^\w.@+_-]+c                  `   \ rS rSrSrSrSrSr\S 5       r	S r
S r\S 5       rS	 rS
 rS rS rS rSS jr\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\SS j5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r\S 5       r \SS j5       r!\S 5       r"Sr#g) 	UserMixin       Nc                    g N selfs    E/var/www/html/env/lib/python3.13/site-packages/social_core/storage.pysaveUserMixin.save           c                8    UR                  U R                  5      $ r   )get_backend_classproviderr   strategys     r   get_backendUserMixin.get_backend   s    ))$--88r   c                Z     UR                  U R                  5      $ ! [         a     g f = fr   )r    r   r   r   s     r   get_backend_instanceUserMixin.get_backend_instance"   s.    	''66 		s    
**c                8    U R                   R                  S5      $ )z0Return access_token stored in extra_data or Noneaccess_token)
extra_datagetr   s    r   r&   UserMixin.access_token(   s     "">22r   c                   U R                   R                  S5      =(       d    U R                   R                  S5      nU R                  U5      nU(       a~  U(       av  [        US5      (       ad  UR                  " U/UQ70 UD6nUR                  X R
                  X`R                   5      nU R                  U5      (       a  U R                  5         g g g g g )Nrefresh_tokenr&   )r'   r(   r#   hasattrr+   uidset_extra_datar   )r   r   argskwargstokenbackendresponser'   s           r   r+   UserMixin.refresh_token-   s    ##O4 
8K8K9
 ++H5W/!B!B,,UDTDVDH ++D((HooVJ"":..		 / "CW5r   c                2   U R                   (       a  SU R                   ;   a   [        U R                   R                  S5      5      n[
        R                  " [        R                  5      nXR                  5       :  a'  [
        R                  " U[        R                  S9nX2-
  $ U R                   R                  S5      nU(       a2  [
        R                  " U[        R                  S9nU[        US9-   U-
  $ [        US9$ g! [        [        4 a     gf = f)a&  Return provider session live seconds. Returns a timedelta ready to
use with session.set_expiry().

If provider returns a timestamp instead of session seconds to live, the
timedelta is inferred from current time (using UTC timezone). None is
returned if there's no value stored or it's invalid.
expiresN)tz	auth_time)seconds)r'   intr(   
ValueError	TypeErrorr   nowr   utc	timestampfromtimestampr   )r   r6   r=   expiry_timer8   	references         r   expiration_timedeltaUserMixin.expiration_timedelta8   s     ??yDOO;doo11)<= ,,x||,C (&44WN"(( ++K8I$229N	!Ig$>>#EEW--% 	* s   $D DDc                "    U R                  5       $ r   )rC   r   s    r   expiration_datetimeUserMixin.expiration_datetimeW   s    ((**r   c                n    U R                  5       nU=(       a    UR                  5       U R                  :*  $ )z6Return true / false if access token is already expired)rC   total_secondsACCESS_TOKEN_EXPIRED_THRESHOLD)r   
expirations     r   access_token_expiredUserMixin.access_token_expired[   s5    ..0
 R((*d.Q.QQ	
r   c                f    U R                  5       (       a  U R                  U5        U R                  $ )zReturns a valid access token.)rL   r+   r&   r   s     r   get_access_tokenUserMixin.get_access_tokenc   s+    $$&&x(   r   c                    U(       ac  U R                   U:w  aS  U R                   (       a;  [        U R                   [        5      (       d  U R                   R                  U5        gXl         gg NT)r'   
isinstancestrupdate)r   r'   s     r   r.   UserMixin.set_extra_datai   sK    $//Z7z$//3'G'G&&z2  #-r   c                Z    [         R                  SU5      n[        R                  SU5      $ )z1Clean username removing any unsupported characterr   )NO_ASCII_REGEXsubNO_SPECIAL_REGEX)clsvalues     r   clean_usernameUserMixin.clean_usernamer   s)     ""2u-##B..r   c                    [        S5      e)z,The given user instance is ready to be savedImplement in subclassNotImplementedErrorr[   users     r   changedUserMixin.changedx        ""9::r   c                    [        S5      e)z"Return the username for given userr`   ra   rc   s     r   get_usernameUserMixin.get_username}   rg   r   c                    [        S5      e)zReturn the user modelr`   ra   r[   s    r   
user_modelUserMixin.user_model   rg   r   c                    [        S5      e)z"Return the max length for usernamer`   ra   rl   s    r   username_max_lengthUserMixin.username_max_length   rg   r   c                    [        S5      e)zGReturn if it's safe to disconnect the social account for the
given userr`   ra   )r[   rd   backend_nameassociation_ids       r   allowed_to_disconnectUserMixin.allowed_to_disconnect   s     ""9::r   c                    [        S5      e)z0Disconnect the social account for the given userr`   ra   )r[   entrys     r   
disconnectUserMixin.disconnect   rg   r   c                    [        S5      e)z
Return True/False if a User instance exists with the given arguments.
Arguments are directly passed to filter() manager method.
r`   ra   r[   r/   r0   s      r   user_existsUserMixin.user_exists   s     ""9::r   c                    [        S5      e)zCreate a user instancer`   ra   r|   s      r   create_userUserMixin.create_user   rg   r   c                    [        S5      e)z!Return user instance for given idr`   ra   )r[   pks     r   get_userUserMixin.get_user   rg   r   c                    [        S5      e)z.Return users instances for given email addressr`   ra   )r[   emails     r   get_users_by_emailUserMixin.get_users_by_email   rg   r   c                    [        S5      e)z0Return UserSocialAuth for given provider and uidr`   ra   )r[   r   r-   s      r   get_social_authUserMixin.get_social_auth   rg   r   c                    [        S5      e)z6Return all the UserSocialAuth instances for given userr`   ra   )r[   rd   r   ids       r   get_social_auth_for_user"UserMixin.get_social_auth_for_user   rg   r   c                    [        S5      e)z/Create a UserSocialAuth instance for given userr`   ra   )r[   rd   r-   r   s       r   create_social_authUserMixin.create_social_auth   rg   r   )r'   r   NN)$__name__
__module____qualname____firstlineno__rJ   r   r-   r'   r   r   r    r#   propertyr&   r+   rC   rF   rL   rO   r.   classmethodr]   re   ri   rm   rp   ru   ry   r}   r   r   r   r   r   r   __static_attributes__r   r   r   r   r      sy   %&"H
CJ 9 3 3	>+
! / /
 ; ; ; ; ; ; ; ; ; ;
 ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;r   r   c                  T    \ rS rSrSrSrSrSr\S 5       r	\S 5       r
\S 5       rSrg	)

NonceMixin   zOne use numbersr   r   c                    [        S5      e)zCreate a Nonce instancer`   ra   )r[   
server_urlr?   salts       r   useNonceMixin.use   rg   r   c                    [        S5      e)zRetrieve a Nonce instancer`   ra   )r[   r   r   s      r   r(   NonceMixin.get   rg   r   c                    [        S5      e)zDelete a Nonce instancer`   ra   )r[   nonces     r   deleteNonceMixin.delete   rg   r   r   N)r   r   r   r   __doc__r   r?   r   r   r   r(   r   r   r   r   r   r   r      sN    JID; ; ; ; ; ;r   r   c                      \ rS rSrSrSrSrSrSrSr	Sr
\SS j5       r\S 5       r\S 5       r\SSS	 jj5       r\S
 5       rSrg)AssociationMixin   zOpenId account associationr   r   Nc                f   ^  SU0nUb  X#S'   [        U 4S jT R                  " S0 UD6 5       S SS9$ )Nr   handlec              3  \   >#    U  H!  oR                   TR                  U5      4v   M#     g 7fr   )r   openid_association).0assocr[   s     r   	<genexpr>(AssociationMixin.oids.<locals>.<genexpr>   s%     VDU5hh..u56DUs   ),c                     U S   R                   $ )Nr
   )issued)xs    r   <lambda>'AssociationMixin.oids.<locals>.<lambda>   s    !A$++r   T)keyreverser   )sortedr(   )r[   r   r   r0   s   `   r   oidsAssociationMixin.oids   sB    
+%8VCGGDUfDUV%
 	
r   c                    UR                   n[        U[        5      (       d  UR                  5       n[	        UR
                  [        R                  " U5      UR                  UR                  UR                  5      $ r   )secretrS   bytesencodeOpenIdAssociationr   base64decodebytesr   lifetime
assoc_type)r[   r   r   s      r   r   #AssociationMixin.openid_association   s\    &%((]]_F LLv&LLNN
 	
r   c                    [        S5      e)zCreate an Association instancer`   ra   )r[   r   associations      r   storeAssociationMixin.store   rg   r   c                    [        S5      e)zGet an Association instancer`   ra   )r[   r   r   s      r   r(   AssociationMixin.get   rg   r   c                    [        S5      e)zRemove an Association instancer`   ra   )r[   ids_to_deletes     r   removeAssociationMixin.remove  rg   r   r   r   r   )r   
str | Noner   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r(   r   r   r   r   r   r   r      s    $JFFFHJ
 
 

 

 ; ; ; ; ; ;r   r   c                  f    \ rS rSrSrSrSr\S 5       rS r	\
S 5       r\
S 5       r\
S 5       rS	rg
)	CodeMixini  r   Fc                    g r   r   r   s    r   r   CodeMixin.save  r   r   c                2    SU l         U R                  5         g rR   )verifiedr   r   s    r   verifyCodeMixin.verify  s    		r   c                @    [         R                  " 5       R                  $ r   uuiduuid4hexrl   s    r   generate_codeCodeMixin.generate_code      zz|r   c                x    U " 5       nXl         U R                  5       Ul        SUl        UR	                  5         U$ )NF)r   r   coder   r   )r[   r   r   s      r   	make_codeCodeMixin.make_code  s3    u
%%'			r   c                    [        S5      eNr`   ra   )r[   r   s     r   get_codeCodeMixin.get_code       !"9::r   )r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r     s`    EDH        ; ;r   r   c                      \ rS rSr% Sr0 rS\S'   S\S'   Sr\S 5       r	\	R                  S 5       r	\S	 5       r\R                  S
 5       rS r\S 5       r\S 5       r\S 5       r\SS j5       r\S 5       rSrg)PartialMixini%  r   dict[str, Any]datar:   	next_stepc                :    U R                   R                  S/ 5      $ Nr/   r   r(   r   s    r   r/   PartialMixin.args+  s    yy}}VR((r   c                     XR                   S'   g r   r   r   r\   s     r   r/   r   /  s    !		&r   c                :    U R                   R                  S0 5      $ Nr0   r   r   s    r   r0   PartialMixin.kwargs3  s    yy}}Xr**r   c                     XR                   S'   g r   r   r   s     r   r0   r   7  s    #		(r   c                @    U R                   S   R                  U5        g r   )r   rU   )r   valuess     r   extend_kwargsPartialMixin.extend_kwargs;  s    		(""6*r   c                @    [         R                  " 5       R                  $ r   r   rl   s    r   generate_tokenPartialMixin.generate_token>  r   r   c                    [        S5      er   ra   r[   r1   s     r   loadPartialMixin.loadB  r   r   c                    [        S5      er   ra   r  s     r   destroyPartialMixin.destroyF  r   r   c                b    U " 5       nXl         X$l        X4l        U R                  5       Ul        U$ r   )r2   r   r   r  r1   )r[   r2   r   r   partials        r   preparePartialMixin.prepareJ  s.    %!%**,r   c                &    UR                  5         U$ r   )r   )r[   r  s     r   r   PartialMixin.storeS  s    r   r   N)r   r:   r   r   )r   r   r   r   r1   r   __annotations__r2   r   r/   setterr0   r   r   r  r  r
  r  r   r   r   r   r   r   r   %  s    ED.NG) ) 
[[" " + + ]]$ $+     ; ; ; ;    r   r   c                  8    \ rS rSr\r\r\r	\
r\r\S 5       rSrg)BaseStorageiY  c                    [        S5      e)z;Check if given exception flags an integrity error in the DBr`   ra   )r[   	exceptions     r   is_integrity_errorBaseStorage.is_integrity_error`  rg   r   r   N)r   r   r   r   r   rd   r   r   r   r   r   r   r   r  r   r  r   r   r   r   r  r  Y  s-    DE"KDG; ;r   r  )r   
__future__r   r   rer   abcr   r   r   r   typingr   openid.associationr	   r   
exceptionsr   compilerX   UNICODErZ   r   r   r   r   r   r  r   r   r   <module>r"     s    # "  	   2 2  ? &,-::nbjj9 g; g;T; ;./; /;d; ;<1 1h
; 
;r   