
    h                     ^    S SK J r   S SKJr  S SKJrJr  S SKJrJr   " S S5      r	\	" 5       r
g)    )datetime)settings)constant_time_comparesalted_hmac)base36_to_intint_to_base36c                       \ rS rSrSrSrSrSrSrS r	S r
S r\" \
\5      rS rS	 r\" \\5      rS
 rS rS rS rS rS rSrg)PasswordResetTokenGenerator   zU
Strategy object used to generate and check tokens for the password
reset mechanism.
z6django.contrib.auth.tokens.PasswordResetTokenGeneratorNc                 8    U R                   =(       d    SU l         g )Nsha256)	algorithmselfs    L/var/www/html/env/lib/python3.13/site-packages/django/contrib/auth/tokens.py__init__$PasswordResetTokenGenerator.__init__   s    38    c                 H    U R                   =(       d    [        R                  $ N)_secretr   
SECRET_KEYr   s    r   _get_secret'PasswordResetTokenGenerator._get_secret   s    ||2x222r   c                     Xl         g r   )r   )r   secrets     r   _set_secret'PasswordResetTokenGenerator._set_secret   s    r   c                 T    U R                   c  [        R                  $ U R                   $ r   )_secret_fallbacksr   SECRET_KEY_FALLBACKSr   s    r   _get_fallbacks*PasswordResetTokenGenerator._get_fallbacks   s&    !!)000%%%r   c                     Xl         g r   )r    )r   	fallbackss     r   _set_fallbacks*PasswordResetTokenGenerator._set_fallbacks#   s    !*r   c                 v    U R                  UU R                  U R                  5       5      U R                  5      $ )zQ
Return a token that can be used once to do a password reset
for the given user.
)_make_token_with_timestamp_num_seconds_nowr   )r   users     r   
make_token&PasswordResetTokenGenerator.make_token(   s5    
 ..diik*KK
 	
r   c                    U(       a  U(       d  g UR                  S5      u  p4 [        U5      nU R                  /U R                  Q H&  n[        U R                  XU5      U5      (       d  M&    O   gU R                  U R                  5       5      U-
  [        R                  :  a  gg! [         a     gf = f! [         a     gf = f)z@
Check that a password reset token is correct for a given user.
F-T)split
ValueErrorr   r   secret_fallbacksr   r)   r*   r+   r   PASSWORD_RESET_TIMEOUT)r   r,   tokents_b36_tsr   s          r   check_token'PasswordResetTokenGenerator.check_token3   s     	C(IF	v&B
 {{;T%:%:;F$//&A   <  diik*R/83R3RR-  		
  		s"   B* B: *
B76B7:
CCc                     [        U5      n[        U R                  U R                  X5      UU R                  S9R                  5       S S S2   nU< SU< 3$ )N)r   r      r0   )r   r   key_salt_make_hash_valuer   	hexdigest)r   r,   	timestampr   r6   hash_strings         r   r)   6PasswordResetTokenGenerator._make_token_with_timestampT   sY     y)!MM!!$2nn	

 )+aC
 !+..r   c                     UR                   c  SOUR                   R                  SSS9nUR                  5       n[        XS5      =(       d    SnUR                   UR
                   U U U 3$ )ab  
Hash the user's primary key, email (if available), and some user state
that's sure to change after a password reset to produce a token that is
invalidated when it's used:
1. The password field will change upon a password reset (even if the
   same password is chosen, due to password salting).
2. The last_login field will usually be updated very shortly after
   a password reset.
Failing those things, settings.PASSWORD_RESET_TIMEOUT eventually
invalidates the token.

Running this data through salted_hmac() prevents password cracking
attempts using the reset token, provided the secret isn't compromised.
N r   )microsecondtzinfo)
last_loginreplaceget_email_field_namegetattrpkpassword)r   r,   r@   login_timestampemail_fieldemails         r   r>   ,PasswordResetTokenGenerator._make_hash_valueb   st    & & ((Qt(D 	
 //12.4"''4==//):9+eWMMr   c                 P    [        U[        SSS5      -
  R                  5       5      $ )Ni     )intr   total_seconds)r   dts     r   r*   (PasswordResetTokenGenerator._num_seconds|   s$    B$1--<<>??r   c                 ,    [         R                  " 5       $ r   )r   nowr   s    r   r+    PasswordResetTokenGenerator._now   s    ||~r   )r   r    r   )__name__
__module____qualname____firstlineno____doc__r=   r   r   r    r   r   r   propertyr   r"   r&   r3   r-   r9   r)   r>   r*   r+   __static_attributes__ r   r   r
   r
      sv    
 HHIG43 k;/F&
+  ?	
B/N4@r   r
   N)r   django.confr   django.utils.cryptor   r   django.utils.httpr   r   r
   default_token_generatorra   r   r   <module>rf      s)       B :y yx 67 r   