§
    ¤”jè  ã                   ól   — d dl m Z  d dlmZ d dlmZmZ d dlmZmZ  G d„ d¦  «        Z	 e	¦   «         Z
dS )é    )Údatetime)Úsettings)Úconstant_time_compareÚsalted_hmac)Úbase36_to_intÚint_to_base36c                   ó”   — e Zd ZdZdZdZdZdZd„ Zd„ Z	d„ Z
 ee	e
¦  «        Zd„ Zd„ Z eee¦  «        Zd	„ Zd
„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚPasswordResetTokenGeneratorza
    Strategy object used to generate and check tokens for the password
    reset mechanism.
    z6django.contrib.auth.tokens.PasswordResetTokenGeneratorNc                 ó"   — | j         pd| _         d S )NÚsha256)Ú	algorithm©Úselfs    úi/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/django/contrib/auth/tokens.pyÚ__init__z$PasswordResetTokenGenerator.__init__   s   € ØœÐ3¨8ˆŒˆˆó    c                 ó(   — | j         pt          j        S ©N)Ú_secretr   Ú
SECRET_KEYr   s    r   Ú_get_secretz'PasswordResetTokenGenerator._get_secret   s   € ØŒ|Ð2�xÔ2Ð2r   c                 ó   — || _         d S r   )r   )r   Úsecrets     r   Ú_set_secretz'PasswordResetTokenGenerator._set_secret   s   € ØˆŒˆˆr   c                 ó6   — | j         €t          j        S | j         S r   )Ú_secret_fallbacksr   ÚSECRET_KEY_FALLBACKSr   s    r   Ú_get_fallbacksz*PasswordResetTokenGenerator._get_fallbacks   s   € ØÔ!Ð)ÝÔ0Ð0ØÔ%Ð%r   c                 ó   — || _         d S r   )r   )r   Ú	fallbackss     r   Ú_set_fallbacksz*PasswordResetTokenGenerator._set_fallbacks#   s   € Ø!*ˆÔÐÐr   c                 ó„   — |                       ||                      |                      ¦   «         ¦  «        | j        ¦  «        S )zi
        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_tokenz&PasswordResetTokenGenerator.make_token(   s=   € ð
 ×.Ò.ØØ×Ò˜dŸiši™kœkÑ*Ô*ØŒKñ
ô 
ð 	
r   c                 ó–  — |r|sdS 	 |                      d¦  «        \  }}n# t          $ r Y dS w xY w	 t          |¦  «        }n# t          $ r Y dS w xY w| j        g| j        ¢D ])}t          |                      |||¦  «        |¦  «        r nŒ*dS |                      |                      ¦   «         ¦  «        |z
  t          j
        k    rdS dS )zP
        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_tokenz'PasswordResetTokenGenerator.check_token3   s  € ð ð 	˜ð 	Ø�5ð	ØŸš CÑ(Ô(‰IˆF�A�AøÝð 	ð 	ð 	Ø�5�5ð	øøøð	Ý˜vÑ&Ô&ˆBˆBøÝð 	ð 	ð 	Ø�5�5ð	øøøð ”{Ð; TÔ%:Ð;ð 	ð 	ˆFÝ$Ø×/Ò/°°b¸&ÑAÔAØñô ð ð �ð	ð �5ð ×Ò˜dŸiši™kœkÑ*Ô*¨RÑ/µ8Ô3RÒRÐRØ�5àˆts   ˆ! ¡
/®/³A Á
AÁAc                 óÆ   — t          |¦  «        }t          | j        |                      ||¦  «        || j        ¬¦  «                             ¦   «         d d d…         }|›d|›�S )N)r   r   é   r)   )r   r   Úkey_saltÚ_make_hash_valuer   Ú	hexdigest)r   r&   Ú	timestampr   r/   Úhash_strings         r   r#   z6PasswordResetTokenGenerator._make_token_with_timestampT   sq   € õ ˜yÑ)Ô)ˆÝ!ØŒMØ×!Ò! $¨	Ñ2Ô2ØØ”nð	
ñ 
ô 
÷
 Š)‰+Œ+ØˆCˆaˆCô
ˆð !˜&˜& + +Ð.Ð.r   c                 óÆ   — |j         €dn|j                              dd¬¦  «        }|                     ¦   «         }t          ||d¦  «        pd}|j        › |j        › |› |› |› �S )aÂ  
        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&   r8   Úlogin_timestampÚemail_fieldÚemails         r   r6   z,PasswordResetTokenGenerator._make_hash_valueb   s}   € ð& ŒÐ&ð ˆBà”×(Ò(°Q¸tÐ(ÑDÔDð 	ð
 ×/Ò/Ñ1Ô1ˆÝ˜˜k¨2Ñ.Ô.Ð4°"ˆØ”'ÐM˜4œ=ÐM¨/ÐM¸9ÐMÀeÐMÐMÐMr   c                 óh   — t          |t          ddd¦  «        z
                       ¦   «         ¦  «        S )NiÑ  é   )Úintr   Útotal_seconds)r   Údts     r   r$   z(PasswordResetTokenGenerator._num_seconds|   s-   € Ý�B� $¨¨1Ñ-Ô-Ñ-×<Ò<Ñ>Ô>Ñ?Ô?Ð?r   c                 ó(   — t          j        ¦   «         S r   )r   Únowr   s    r   r%   z PasswordResetTokenGenerator._now   s   € åŒ|‰~Œ~Ðr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r5   r   r   r   r   r   r   Úpropertyr   r   r!   r,   r'   r2   r#   r6   r$   r%   © r   r   r
   r
      s	  € € € € € ðð ð
 H€HØ€IØ€GØÐð4ð 4ð 4ð3ð 3ð 3ðð ð ð ˆX�k ;Ñ/Ô/€Fð&ð &ð &ð
+ð +ð +ð  �x °Ñ?Ô?Ðð	
ð 	
ð 	
ðð ð ðB/ð /ð /ðNð Nð Nð4@ð @ð @ðð ð ð ð r   r
   N)r   Údjango.confr   Údjango.utils.cryptor   r   Údjango.utils.httpr   r   r
   Údefault_token_generatorrS   r   r   ú<module>rX      s¡   ðØ Ð Ð Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  Ø BÐ BÐ BÐ BÐ BÐ BÐ BÐ BØ :Ð :Ð :Ð :Ð :Ð :Ð :Ð :ðyð yð yð yð yñ yô yð yðx 6Ð5Ñ7Ô7Ð Ð Ð r   