
    (phD                     z   S SK r S SKJr  S SKJrJrJr  S SKJrJ	r	  S SK
Jr  S SKJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  \" 5       r S r! " S S\RD                  5      r# " S S\RH                  5      r% " S S\RL                  5      r' " S S\RP                  5      r) " S S\)5      r* " S S\RP                  5      r+ " S S\RX                  5      r- " S S \RX                  5      r. " S! S"\RX                  5      r/ " S# S$\/5      r0 " S% S&\RX                  5      r1g)'    N)forms)authenticateget_user_modelpassword_validation)UNUSABLE_PASSWORD_PREFIXidentify_hasher)User)default_token_generator)get_current_site)ValidationError)EmailMultiAlternatives)loader)force_bytes)urlsafe_base64_encode)capfirst)gettext)gettext_lazyc                     [         R                  " SU 5      R                  5       [         R                  " SU5      R                  5       :H  $ )z
Perform case-insensitive comparison of two identifiers, using the
recommended algorithm from Unicode Technical Report 36, section
2.11.2(B)(2).
NFKC)unicodedata	normalizecasefold)s1s2s     L/var/www/html/venv/lib/python3.13/site-packages/django/contrib/auth/forms.py_unicode_ci_comparer      s@     	fb)224  ,557	8    c                   6   ^  \ rS rSrSrSrU 4S jrS rSrU =r	$ )ReadOnlyPasswordHashWidget!   z)auth/widgets/read_only_password_hash.htmlTc                   > [         T	U ]  XU5      n/ nU(       a  UR                  [        5      (       a  UR	                  S[        S5      05        OQ [        U5      nUR                  U5      R                  5        H"  u  pxUR	                  [        U5      US.5        M$     XTS'   U$ ! [         a    UR	                  S[        S5      05         N.f = f)NlabelzNo password set.)r"   valuez5Invalid password format or unknown hashing algorithm.summary)
superget_context
startswithr   appendr   r   safe_summaryitems
ValueError)
selfnamer#   attrscontextr$   hasherkeyvalue_	__class__s
            r   r&   &ReadOnlyPasswordHashWidget.get_context%   s    '%d59(()ABBNNGW-?%@ABM(/ $*#6#6u#=#C#C#EKCNNWS\F#KL $F$	  S"s   B) )&CCc                     g N )r,   id_s     r   id_for_label'ReadOnlyPasswordHashWidget.id_for_label;   s    r   r7   )
__name__
__module____qualname____firstlineno__template_name	read_onlyr&   r9   __static_attributes____classcell__r3   s   @r   r   r   !   s    ?MI, r   r   c                   ,   ^  \ rS rSr\rU 4S jrSrU =r$ )ReadOnlyPasswordHashField?   c                 n   > UR                  SS5        UR                  SS5        [        TU ]  " U0 UD6  g )NrequiredFdisabledT)
setdefaultr%   __init__r,   argskwargsr3   s      r   rK   "ReadOnlyPasswordHashField.__init__B   s5    *e,*d+$)&)r   r7   )	r;   r<   r=   r>   r   widgetrK   rA   rB   rC   s   @r   rE   rE   ?   s    'F* *r   rE   c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )UsernameFieldH   c                    > [         TU ]  U5      nU R                  b  [        U5      U R                  :  a  U$ [        R
                  " SU5      $ )Nr   )r%   	to_python
max_lengthlenr   r   )r,   r#   r3   s     r   rU   UsernameField.to_pythonI   sE    !%(??&3u:+G L$$VU33r   c                 0   > 0 [         TU ]  U5      ESSS.E$ )Nnoneusername)autocapitalizeautocomplete)r%   widget_attrs)r,   rP   r3   s     r   r^   UsernameField.widget_attrsT   s*    
g"6*
$&
 	
r   r7   )r;   r<   r=   r>   rU   r^   rA   rB   rC   s   @r   rR   rR   H   s    	4
 
r   rR   c                   D  ^  \ rS rSrSrS\" S5      0r\R                  " \" S5      S\R                  " SS0S	9\
R                  " 5       S
9r\R                  " \" S5      \R                  " SS0S	9S\" S5      S9r " S S5      rU 4S jrS rU 4S jrSU 4S jjrSrU =r$ )BaseUserCreationForm\   zW
A form that creates a user, with no privileges, from the given username and
password.
password_mismatch'   The two password fields didn’t match.PasswordFr]   new-passwordr.   )r"   striprP   	help_textzPassword confirmation4Enter the same password as before, for verification.r"   rP   rh   ri   c                   $    \ rS rSr\rSrS\0rSr	g)BaseUserCreationForm.Metar   )r[   r[   r7   N
r;   r<   r=   r>   r	   modelfieldsrR   field_classesrA   r7   r   r   Metarm   r   s    #]3r   rs   c                   > [         TU ]  " U0 UD6  U R                  R                  R                  U R
                  ;   aE  SU R
                  U R                  R                  R                     R                  R                  S'   g g )NT	autofocus)r%   rK   _metarp   USERNAME_FIELDrq   rP   r.   rL   s      r   rK   BaseUserCreationForm.__init__w   sm    $)&)::**dkk9  KK

((778??EE :r   c                     U R                   R                  S5      nU R                   R                  S5      nU(       a#  U(       a  X:w  a  [        U R                  S   SS9eU$ N	password1	password2rc   code)cleaned_datagetr   error_messagesr,   r{   r|   s      r   clean_password2$BaseUserCreationForm.clean_password2~   s_    %%))+6	%%))+6	y'=!##$78(  r   c                    > [         TU ]  5         U R                  R                  S5      nU(       a"   [        R
                  " XR                  5        g g ! [         a  nU R                  SU5         S nAg S nAff = f)Nr|   )	r%   _post_cleanr   r   r   validate_passwordinstancer   	add_error)r,   passworderrorr3   s      r   r    BaseUserCreationForm._post_clean   sh     $$((53#55hN  # 3{E223s    A 
A;A66A;c                    > [         TU ]  SS9nUR                  U R                  S   5        U(       a1  UR                  5         [	        U S5      (       a  U R                  5         U$ )NF)commitr{   save_m2m)r%   saveset_passwordr   hasattrr   )r,   r   userr3   s      r   r   BaseUserCreationForm.save   sS    w|5|)$++K89IIKtZ((r   r7   T)r;   r<   r=   r>   __doc___r   r   	CharFieldPasswordInputr   "password_validators_help_text_htmlr{   r|   rs   rK   r   r   r   rA   rB   rC   s   @r   ra   ra   \   s     	QHIN 
m""..)IJ%HHJ	I '(""..)IJJK	I4 4
	3 r   ra   c                       \ rS rSrS rSrg)UserCreationForm   c           	      b   U R                   R                  S5      nU(       a  U R                  R                  R                  R                  US9R                  5       (       aL  U R                  [        SU R                  R                  U R                  R                  S/5      05      5        gU$ )z*Reject usernames that differ only in case.r[   )username__iexactN)r   r   rv   rp   objectsfilterexists_update_errorsr   r   unique_error_message)r,   r[   s     r   clean_usernameUserCreationForm.clean_username   s    $$((4

  ((///JQQSS"DMM$F$F JJ,,zl% Or   r7   N)r;   r<   r=   r>   r   rA   r7   r   r   r   r      s    r   r   c                   b   ^  \ rS rSr\" \" S5      \" S5      S9r " S S5      rU 4S jrSr	U =r
$ )	UserChangeForm   re   u   Raw passwords are not stored, so there is no way to see this user’s password, but you can change the password using <a href="{}">this form</a>.)r"   ri   c                   $    \ rS rSr\rSrS\0rSr	g)UserChangeForm.Meta   __all__r[   r7   Nro   r7   r   r   rs   r      s    #]3r   rs   c                 `  > [         TU ]  " U0 UD6  U R                  R                  S5      nU(       a8  UR                  R                  SU R                  R                   S35      Ul        U R                  R                  S5      nU(       a!  UR                  R                  S5      Ul        g g )Nr   z../../z
/password/user_permissionscontent_type)
r%   rK   rq   r   ri   formatr   pkquerysetselect_related)r,   rM   rN   r   r   r3   s        r   rK   UserChangeForm.__init__   s    $)&);;??:.!)!3!3!:!:))**5"H  ;;??+=>(8(A(A(P(P)% r   r7   )r;   r<   r=   r>   rE   r   r   rs   rK   rA   rB   rC   s   @r   r   r      s5    (
m*
H4 4
 r   r   c                      ^  \ rS rSrSr\" \R                  " SS0S9S9r\R                  " \
" S5      S\R                  " S	S
0S9S9r\
" S5      \
" S5      S.rSU 4S jjrS rS rS rS rSrU =r$ )AuthenticationForm   zg
Base class for authenticating users. Extend this to get a form that accepts
username/password logins.
ru   Trg   )rP   re   Fr]   current-passwordr"   rh   rP   z^Please enter a correct %(username)s and password. Note that both fields may be case-sensitive.zThis account is inactive.)invalid_logininactivec                   > Xl         SU l        [        TU ]  " U0 UD6  [        R
                  R                  [        R                  5      U l        U R                  R                  =(       d    SnX@R                  S   l	        X@R                  S   R                  R                  S'   U R                  S   R                  c2  [        U R                  R                  5      U R                  S   l        gg)zy
The 'request' parameter is set for custom auth use by subclasses.
The form data comes in via the standard 'data' kwarg.
N   r[   	maxlength)request
user_cacher%   rK   	UserModelrv   	get_fieldrw   username_fieldrV   rq   rP   r.   r"   r   verbose_name)r,   r   rM   rN   username_max_lengthr3   s        r   rK   AuthenticationForm.__init__   s    
 $)&) (oo77	8P8PQ"11<<C-@J*<OJ&&,,[9;;z"((0,4T5H5H5U5U,VDKK
#) 1r   c                 <   U R                   R                  S5      nU R                   R                  S5      nUbX  U(       aQ  [        U R                  XS9U l        U R                  c  U R                  5       eU R                  U R                  5        U R                   $ )Nr[   r   )r[   r   )r   r   r   r   r   get_invalid_login_errorconfirm_login_allowed)r,   r[   r   s      r   cleanAuthenticationForm.clean   s    $$((4$$((4H*xDO &2244**4??;   r   c                 T    UR                   (       d  [        U R                  S   SS9eg)a]  
Controls whether the given User may log in. This is a policy setting,
independent of end-user authentication. This default behavior is to
allow login by active users, and reject login by inactive users.

If the given user cannot log in, this method should raise a
``ValidationError``.

If the given user may log in, this method should return None.
r   r}   N)	is_activer   r   )r,   r   s     r   r   (AuthenticationForm.confirm_login_allowed  s.     ~~!##J/  r   c                     U R                   $ r6   )r   r,   s    r   get_userAuthenticationForm.get_user  s    r   c                 ^    [        U R                  S   SSU R                  R                  0S9$ )Nr   r[   )r~   params)r   r   r   r   r   s    r   r   *AuthenticationForm.get_invalid_login_error  s4    0  3 3 @ @A
 	
r   )r   r   r   r6   )r;   r<   r=   r>   r   rR   r   	TextInputr[   r   r   r   r   r   rK   r   r   r   r   rA   rB   rC   s   @r   r   r      s    
 EOO;:M$NOH
m"".:L)MNH ,
 12NW"!"
 
r   r   c            	           \ rS rSr\R
                  " \" S5      S\R                  " SS0S9S9r SS	 jr	S
 r
SSSS\SSSS4	S jrSrg)PasswordResetFormi   Emailr   r]   emailrg   )r"   rV   rP   Nc                 *   [         R                  " X5      nSR                  UR                  5       5      n[         R                  " X#5      n[	        XxXE/5      n	Ub(  [         R                  " Xc5      n
U	R                  U
S5        U	R                  5         g)z?
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
 Nz	text/html)r   render_to_stringjoin
splitlinesr   attach_alternativesend)r,   subject_template_nameemail_template_namer/   
from_emailto_emailhtml_email_template_namesubjectbodyemail_message
html_emails              r   	send_mailPasswordResetForm.send_mail'  s~     ))*?I''',,./&&':D.wj*U#/001ISJ,,ZEr   c                    ^^ [         R                  5       m[         R                  R                  " S0 ST-  TSS0D6nUU4S jU 5       $ )zGiven an email, return matching user(s) who should receive a reset.

This allows subclasses to more easily customize the default policies
that prevent inactive users and users with unusable passwords from
resetting their password.
z
%s__iexactr   Tc              3      >#    U  H;  nUR                  5       (       d  M  [        T[        UT5      5      (       d  M7  Uv   M=     g 7fr6   )has_usable_passwordr   getattr).0ur   email_field_names     r   	<genexpr>.PasswordResetForm.get_users.<locals>.<genexpr>M  s?      
!$$&  $E716F+GH A!s   AA	Ar7   )r   get_email_field_name_default_managerr   )r,   r   active_usersr   s    ` @r   	get_usersPasswordResetForm.get_users?  sV     %99; 1188 
//T

!
 	
r   z'registration/password_reset_subject.txtz&registration/password_reset_email.htmlFc
           
         U R                   S   n
U(       d$  [        U5      nUR                  nUR                  nOU=p[        R                  5       nU R                  U
5       Hk  n[        X5      nUUU[        [        UR                  5      5      UUR                  U5      U(       a  SOSS.U	=(       d    0 EnU R                  UUUUUUS9  Mm     g)zN
Generate a one-use only link for resetting password and send it to the
user.
r   httpshttp)r   domain	site_nameuidr   tokenprotocol)r   N)r   r   r-   r   r   r   r   r   r   r   r   
make_tokenr   )r,   domain_overrider   r   	use_httpstoken_generatorr   r   r   extra_email_contextr   current_siter   r   r   r   
user_emailr/   s                     r   r   PasswordResetForm.saveT  s      !!'*+G4L$))I!((F!00I$99;NN5)D 8J# &,[-AB(33D9'0Gf	 ',"	G NN%#)A   *r   r7   r6   )r;   r<   r=   r>   r   
EmailFieldr   
EmailInputr   r   r   r
   r   rA   r7   r   r   r   r      s`    j~w&?@E "&0
. GD/!% +r   r   c                     ^  \ rS rSrSrS\" S5      0r\R                  " \" S5      \R                  " SS0S9S	\
R                  " 5       S
9r\R                  " \" S5      S	\R                  " SS0S9S9rU 4S jrS rSS jrSrU =r$ )SetPasswordFormi  zN
A form that lets a user set their password without entering the old
password
rc   rd   zNew passwordr]   rf   rg   Frk   zNew password confirmationr   c                 2   > Xl         [        TU ]  " U0 UD6  g r6   r   r%   rK   r,   r   rM   rN   r3   s       r   rK   SetPasswordForm.__init__      	$)&)r   c                    U R                   R                  S5      nU R                   R                  S5      nU(       a#  U(       a  X:w  a  [        U R                  S   SS9e[        R
                  " X R                  5        U$ )Nnew_password1new_password2rc   r}   r   r   r   r   r   r   r   r   s      r   clean_new_password2#SetPasswordForm.clean_new_password2  sq    %%))/:	%%))/:	y'=!##$78(  	--iCr   c                     U R                   S   nU R                  R                  U5        U(       a  U R                  R                  5         U R                  $ )Nr  r   r   r   r   r,   r   r   s      r   r   SetPasswordForm.save  s?    $$_5		x(IINNyyr   r   r   )r;   r<   r=   r>   r   r   r   r   r   r   r   r   r  r  rK   r  r   rA   rB   rC   s   @r   r  r    s     	QHIN OO""..)IJ%HHJ	M OO+,""..)IJM*	 r   r  c            	           \ rS rSrSr0 \R                  ES\" S5      0Er\R                  " \" S5      S\R                  " SSS	.S
9S9r/ SQrS rSrg)PasswordChangeFormi  zO
A form that lets a user change their password by entering their old
password.
password_incorrectzAYour old password was entered incorrectly. Please enter it again.zOld passwordFr   Tr]   ru   rg   r   )old_passwordr  r  c                     U R                   S   nU R                  R                  U5      (       d  [        U R                  S   SS9eU$ )z2
Validate that the old_password field is correct.
r$  r"  r}   )r   r   check_passwordr   r   )r,   r$  s     r   clean_old_password%PasswordChangeForm.clean_old_password  sP     ((8yy''55!##$89)  r   r7   N)r;   r<   r=   r>   r   r  r   r   r   r   r   r$  field_orderr'  rA   r7   r   r   r!  r!    sl    


(
(aO
N ??""#5DI
L EK
r   r!  c                   :  ^  \ rS rSrSrS\" S5      0rSr\R                  " \" S5      \R                  " SSS	.S
9S\R                  " 5       S9r\R                  " \" S5      \R                  " SS0S
9S\" S5      S9rU 4S jrS rSS jr\U 4S j5       rSrU =r$ )AdminPasswordChangeFormi  zF
A form used to change the password of a user in the admin interface.
rc   rd   rH   re   rf   Tr#  rg   Frk   zPassword (again)r]   rj   c                 2   > Xl         [        TU ]  " U0 UD6  g r6   r  r  s       r   rK    AdminPasswordChangeForm.__init__  r  r   c                    U R                   R                  S5      nU R                   R                  S5      nU(       a#  U(       a  X:w  a  [        U R                  S   SS9e[        R
                  " X R                  5        U$ rz   r  r   s      r   r   'AdminPasswordChangeForm.clean_password2  sq    %%))+6	%%))+6	y'=!##$78(  	--iCr   c                     U R                   S   nU R                  R                  U5        U(       a  U R                  R                  5         U R                  $ )zSave the new password.r{   r  r  s      r   r   AdminPasswordChangeForm.save  s?    $$[1		x(IINNyyr   c                 V   > [         TU ]  nU R                   H  nX!;  d  M
  / s  $    S/$ )Nr   )r%   changed_datarq   )r,   datar-   r3   s      r   r3  $AdminPasswordChangeForm.changed_data   s0    w#KKD	   |r   r  r   )r;   r<   r=   r>   r   r   r   required_css_classr   r   r   r   r   r{   r|   rK   r   r   propertyr3  rA   rB   rC   s   @r   r+  r+    s    
 	QHIN $
m""#1E
 %HHJI "#""..)IJJK	I*	  r   r+  )2r   djangor   django.contrib.authr   r   r   django.contrib.auth.hashersr   r   django.contrib.auth.modelsr	   django.contrib.auth.tokensr
   django.contrib.sites.shortcutsr   django.core.exceptionsr   django.core.mailr   django.templater   django.utils.encodingr   django.utils.httpr   django.utils.textr   django.utils.translationr   r   r   r   r   Widgetr   FieldrE   r   rR   	ModelFormra   r   r   Formr   r   r  r!  r+  r7   r   r   <module>rI     s      Q Q Q + > ; 2 3 " - 3 & , 6		 <* *
EOO 
(>5?? >B+ *U__ :N
 N
b_

 _D)ejj )X   F5ejj 5r   