
    hS                        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	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   S SK!J"r"  \" 5       r#\ RH                  " S5      r%S r& " S S\RN                  5      r( " S S\RR                  5      r* " S S\RV                  5      r, " S S5      r- " S S5      r. " S S\-\R^                  5      r0 " S S \05      r1 " S! S"\R^                  5      r2 " S# S$\Rf                  5      r4 " S% S&\Rf                  5      r5 " S' S(\-\Rf                  5      r6 " S) S*\65      r7 " S+ S,\.\-\Rf                  5      r8 " S- S.\.\15      r9g)/    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_lazy)sensitive_variableszdjango.contrib.authc                     [         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     K/var/www/html/env/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U=(       a    UR                  [        5      (       + n/ nU(       aR   [	        U5      nUR                  U5      R                  5        H"  u  pUR                  [        U5      U	S.5        M$     OUR                  S[        S5      05        XdS'   U(       a  [        S5      O
[        S5      US'   U$ ! [         a    UR                  S[        S5      05         NNf = f)	N)labelvaluer#   z5Invalid password format or unknown hashing algorithm.zNo password set.summaryzReset passwordzSet passwordbutton_label)superget_context
startswithr   r   safe_summaryitemsappendr   
ValueError_)selfnamer$   attrscontextusable_passwordr%   hasherkeyvalue_	__class__s             r   r(   &ReadOnlyPasswordHashWidget.get_context(   s    '%d59R(8(89Q(R$RM(/ $*#6#6u#=#C#C#EKCNNWS\F#KL $F NNGW-?%@AB$	#2A.8I 	 #  S"s   C &C;:C;c                     g N )r/   id_s     r   id_for_label'ReadOnlyPasswordHashWidget.id_for_labelB   s    r   r;   )
__name__
__module____qualname____firstlineno__template_name	read_onlyr(   r=   __static_attributes____classcell__r7   s   @r   r    r    $   s    ?MI4 r   r    c                   ,   ^  \ rS rSr\rU 4S jrSrU =r$ )ReadOnlyPasswordHashFieldF   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kwargsr7   s      r   rO   "ReadOnlyPasswordHashField.__init__I   s5    *e,*d+$)&)r   r;   )	r?   r@   rA   rB   r    widgetrO   rE   rF   rG   s   @r   rI   rI   F   s    'F* *r   rI   c                   4   ^  \ rS rSrU 4S jrU 4S jrSrU =r$ )UsernameFieldO   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$   r7   s     r   rY   UsernameField.to_pythonP   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/   rT   r7   s     r   rb   UsernameField.widget_attrs[   s*    
g"6*
$&
 	
r   r;   )r?   r@   rA   rB   rY   rb   rE   rF   rG   s   @r   rV   rV   O   s    	4
 
r   rV   c                   ~    \ rS rSrSrS\" S5      0r\\" S5      \" S5      4S j5       r  SS jr	SS	 jr
SS
 jrSrg)SetPasswordMixinc   z;
Form mixin that validates and sets a password for a user.
password_mismatchu'   The two password fields didn’t match.PasswordzPassword confirmationc           	          [         R                  " U SS[         R                  " SS0S9[        R                  " 5       S9n[         R                  " US[         R                  " SS0S9S[        S5      S9nX#4$ )	NTFra   znew-passwordr1   )r#   rL   striprT   	help_textz4Enter the same password as before, for verification.)r#   rL   rT   rk   rl   )r   	CharFieldPasswordInputr   "password_validators_help_text_htmlr.   )label1label2	password1	password2s       r   create_password_fields'SetPasswordMixin.create_password_fieldsl   sx    OO&&nn-MN)LLN
	 OO&&nn-MNNO
	 ##r   c                     U R                   R                  U5      nU R                   R                  U5      nU(       a7  U(       a/  X4:w  a)  [        U R                  S   SS9nU R	                  X%5        g g g g )Nrg   code)cleaned_datagetr   error_messages	add_error)r/   password1_field_namepassword2_field_namerr   rs   errors         r   validate_passwords#SetPasswordMixin.validate_passwords~   sp    
 %%))*>?	%%))*>?	y'=###$78(E NN/7 (>9r   c                     U R                   R                  U5      nU(       a   [        R                  " X15        g g ! [         a  nU R                  X$5         S nAg S nAff = fr:   )ry   rz   r   validate_passwordr   r|   )r/   userpassword_field_namepasswordr   s        r   validate_password_for_user+SetPasswordMixin.validate_password_for_user   sV    $$(()<=;#55hE  # ;2::;s   < 
A!AA!c                 p    UR                  U R                  U   5        U(       a  UR                  5         U$ r:   )set_passwordry   save)r/   r   r   commits       r   set_password_and_save&SetPasswordMixin.set_password_and_save   s-    $++,?@AIIKr   r;   N)rr   rs   )rs   )rr   T)r?   r@   rA   rB   __doc__r.   r{   staticmethodrt   r   r   r   rE   r;   r   r   re   re   c   sU    
 	QHIN &'
mA>U<V $ $& )(8;r   re   c                      ^  \ rS rSrSr\" S5      r\\4S j5       r\	" SS5         SU 4S jj5       r
U 4S jrSU 4S	 jjrS
rU =r$ )SetUnusablePasswordMixin   z
Form mixin that allows setting an unusable password for a user.

This mixin should be used in combination with `SetPasswordMixin`.
zWhether the user will be able to authenticate using a password or not. If disabled, they may still be able to authenticate using other backends, such as Single Sign-On or LDAP.c           
          [         R                  " [        S5      SS[        S5      [        S5      S.[         R                  " SS0S	9U S
9$ )NzPassword-based authenticationFtrueEnabledDisabled)r   falseclasszradiolist inlinerj   )r#   rL   initialchoicesrT   rl   )r   ChoiceFieldr.   RadioSelect)rl   s    r   create_usable_password_field5SetUnusablePasswordMixin.create_usable_password_field   sK      34y\AjMB$$G5G+HI
 	
r   rr   rs   c                 &  > U R                   R                  US 5      S:g  nX@R                   S'   U(       d  g U R                   R                  U5      nU R                   R                  U5      nU(       dD  XR                  ;  a5  [	        U R
                  U   R                  S   SS9nU R                  X5        U(       dD  X R                  ;  a5  [	        U R
                  U   R                  S   SS9nU R                  X'5        [        TU ]%  X5        g )Nr   set_usable_passwordrL   rw   )
ry   poprz   errorsr   fieldsr{   r|   r'   r   )	r/   r}   r~   usable_password_field_namer3   rr   rs   r   r7   s	           r   r   +SetUnusablePasswordMixin.validate_passwords   s     !!"<dCwN 	 4C/0%%))*>?	%%))*>?	1D#01@@LE NN/71D#01@@LE NN/7"#7Nr   c                 R   > U R                   S   (       a  [        TU ]  " U40 UD6  g g )Nr   )ry   r'   r   )r/   r   rR   r7   s      r   r   3SetUnusablePasswordMixin.validate_password_for_user   s)    23G.t>v> 4r   c                    > U R                   S   (       a  [        TU ]  " U40 UDSU0D6nU$ UR                  5         U(       a  UR	                  5         U$ )Nr   r   )ry   r'   r   set_unusable_passwordr   )r/   r   r   rR   r7   s       r   r   .SetUnusablePasswordMixin.set_password_and_save   sQ    2370OOOD
  &&(		r   r;   )rr   rs   r3   T)r?   r@   rA   rB   r   r.   usable_password_help_textr   r   r   r   r   r   rE   rF   rG   s   @r   r   r      si     !"	*! /H 
 
 k2 )(#4	O 3OB? r   r   c                      ^  \ rS rSrSr\R                  5       u  rr " S S5      r	U 4S jr
U 4S jrU 4S jrS
U 4S jjrS	rU =r$ )BaseUserCreationForm   z
A form that creates a user, with no privileges, from the given username and
password.

This is the documented base class for customizing the user creation form.
It should be kept mostly unchanged to ensure consistency and compatibility.
c                   $    \ rS rSr\rSrS\0rSr	g)BaseUserCreationForm.Meta   )r_   r_   r;   N
r?   r@   rA   rB   r	   modelr   rV   field_classesrE   r;   r   r   Metar      s    #]3r   r   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'   rO   _metar   USERNAME_FIELDr   rT   r1   rP   s      r   rO   BaseUserCreationForm.__init__   sm    $)&)::**dkk9  KK

((778??EE :r   c                 @   > U R                  5         [        TU ]	  5       $ r:   )r   r'   cleanr/   r7   s    r   r   BaseUserCreationForm.clean   s    !w}r   c                 X   > [         TU ]  5         U R                  U R                  5        g r:   )r'   _post_cleanr   instancer   s    r   r    BaseUserCreationForm._post_clean   s"     	''6r   c                    > [         TU ]  SS9nU R                  X!S9nU(       a!  [        U S5      (       a  U R	                  5         U$ )NFr   save_m2m)r'   r   r   hasattrr   )r/   r   r   r7   s      r   r   BaseUserCreationForm.save  sC    w|5|)))$)>gdJ//MMOr   r;   r   )r?   r@   rA   rB   r   re   rt   rr   rs   r   rO   r   r   r   rE   rF   rG   s   @r   r   r      s@     ,BBDIy4 4
7 r   r   c                       \ rS rSrS rSrg)UserCreationFormi  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)ry   rz   r   r   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   r;   N)r?   r@   rA   rB   r   rE   r;   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
$ )	UserChangeFormi"  rh   uN   Raw passwords are not stored, so there is no way to see the user’s password.)r#   rl   c                   $    \ rS rSr\rSrS\0rSr	g)UserChangeForm.Metai+  __all__r_   r;   Nr   r;   r   r   r   r   +  s    #]3r   r   c                 p  > [         TU ]  " U0 UD6  U R                  R                  S5      nU(       a@  U R                  (       a/  U R                  R                  5       (       d  [        S5      Ul        U R                  R                  S5      nU(       a!  UR                  R                  S5      Ul        g g )Nr   zIEnable password-based authentication for this user by setting a password.user_permissionscontent_type)
r'   rO   r   rz   r   has_usable_passwordr.   rl   querysetselect_related)r/   rQ   rR   r   r   r7   s        r   rO   UserChangeForm.__init__0  s    $)&);;??:.}}T]]%F%F%H%H%& &"  ;;??+=>(8(A(A(P(P)% r   r;   )r?   r@   rA   rB   rI   r.   r   r   rO   rE   rF   rG   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$ )AuthenticationFormi@  zg
Base class for authenticating users. Extend this to get a form that accepts
username/password logins.
r   Trj   )rT   rh   Fra   current-passwordr#   rk   rT   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'   rO   	UserModelr   	get_fieldr   username_fieldrZ   r   rT   r1   r#   r   verbose_name)r/   r   rQ   rR   username_max_lengthr7   s        r   rO   AuthenticationForm.__init__U  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   )ry   rz   r   r   r   get_invalid_login_errorconfirm_login_allowed)r/   r_   r   s      r   r   AuthenticationForm.cleanf  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   rw   N)	is_activer   r{   )r/   r   s     r   r   (AuthenticationForm.confirm_login_allowedu  s.     ~~!##J/  r   c                     U R                   $ r:   )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_   )rx   params)r   r{   r   r   r   s    r   r   *AuthenticationForm.get_invalid_login_error  s4    0  3 3 @ @A
 	
r   )r   r   r   r:   )r?   r@   rA   rB   r   rV   r   	TextInputr_   rm   r.   rn   r   r{   rO   r   r   r   r   rE   rF   rG   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   ra   emailrj   )r#   rZ   rT   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! [         a&    [        R                  SUS   R                  5         gf = f)z?
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
 Nz	text/htmlz)Failed to send password reset email to %sr   )r   render_to_stringjoin
splitlinesr   attach_alternativesend	Exceptionlogger	exceptionpk)r/   subject_template_nameemail_template_namer2   
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	  	;WV_=O=O	s   B -CC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r:   )r   r   getattr).0ur  email_field_names     r   	<genexpr>.PasswordResetForm.get_users.<locals>.<genexpr>  s?      
!$$&  $E716F+GH A!s   AA	Ar;   )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)ry   r   r0   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_emailr2   s                     r   r   PasswordResetForm.save  s      !!'*+G4L$))I!((F!00I$99;NN5)D 8J# &,[-AB(33D9'0Gf	 ',"	G NN%#)A   *r   r;   r:   )r?   r@   rA   rB   r   
EmailFieldr.   
EmailInputr  r  r&  r
   r   rE   r;   r   r   r  r    s`    j~w&?@E "&:
. GD/!% +r   r  c                      ^  \ rS rSrSr\R                  \" S5      \" S5      S9u  rr	U 4S jr
U 4S j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
zNew passwordzNew password confirmation)rp   rq   c                 2   > Xl         [        TU ]  " U0 UD6  g r:   )r   r'   rO   r/   r   rQ   rR   r7   s       r   rO   SetPasswordForm.__init__  s    	$)&)r   c                 |   > U R                  SS5        U R                  U R                  S5        [        TU ]  5       $ )Nnew_password1new_password2r   r   r   r'   r   r   s    r   r   SetPasswordForm.clean  s3    A''		?Cw}r   c                 8    U R                  U R                  SUS9$ )Nr@  r   r   r   r/   r   s     r   r   SetPasswordForm.save  s    ))$))_V)TTr   r   r   )r?   r@   rA   rB   r   re   rt   r.   r@  rA  rO   r   r   rE   rF   rG   s   @r   r;  r;    sK    
 $4#J#J +F)G $K $ M=*
U U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)ra   r   rj   r   )old_passwordr@  rA  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.
rL  rK  rw   )ry   r   check_passwordr   r{   )r/   rL  s     r   clean_old_password%PasswordChangeForm.clean_old_password%  sP     ((8yy''55!##$89)  r   r;   N)r?   r@   rA   rB   r   r;  r{   r.   r   rm   rn   rL  field_orderrO  rE   r;   r   r   rJ  rJ    sl    


(
(aO
N ??""#5DI
L EK
r   rJ  c                      ^  \ rS rSrSrSr\R                  S-   r\R                  5       u  r
rU 4S jrU 4S jrS
S jr\U 4S j5       rS	rU =r$ )AdminPasswordChangeFormi2  zF
A form used to change the password of a user in the admin interface.
rL   z<ul id="id_unusable_warning" class="messagelist"><li class="warning">If disabled, the current password for this user will be lost.</li></ul>c                 f  > Xl         [        TU ]  " U0 UD6  SU R                  S   R                  R
                  S'   U R                   R                  5       (       aU  SU R                  S   l        SU R                  S   l        [        R                  U R                  5      U R                  S'   g g )NTrr   r   Frs   r3   )r   r'   rO   r   rT   r1   r   rL   r   r   r   r=  s       r   rO    AdminPasswordChangeForm.__init__>  s    	$)&)=AK ''--k:99((**05DKK$-05DKK$-(EE22 KK)* +r   c                 v   > U R                  5         U R                  U R                  5        [        TU ]  5       $ r:   rB  r   s    r   r   AdminPasswordChangeForm.cleanK  s-    !''		2w}r   c                 6    U R                  U R                  US9$ )zSave the new password.r   rE  rF  s     r   r   AdminPasswordChangeForm.saveP  s    ))$))F)CCr   c                 F   > [         TU ]  nSU;   d  SU;   a	  SU;   a  S/$ / $ )Nr   rr   rs   r   )r'   changed_data)r/   datar7   s     r   r[  $AdminPasswordChangeForm.changed_dataT  s1    w# D(K4,?KSWDW<	r   rH  r   )r?   r@   rA   rB   r   required_css_classr   r   re   rt   rr   rs   rO   r   r   propertyr[  rE   rF   rG   s   @r   rS  rS  2  s`     $ 8 R R	R! ,BBDIy
D  r   rS  c                   H   ^  \ rS rSr\R                  5       rU 4S jrSrU =r	$ )AdminUserCreationFormi\  c                 v   > [         TU ]  " U0 UD6  SU R                  S   l        SU R                  S   l        g )NFrr   rs   )r'   rO   r   rL   rP   s      r   rO   AdminUserCreationForm.__init__`  s7    $)&),1K ),1K )r   r;   )
r?   r@   rA   rB   r   r   r3   rO   rE   rF   rG   s   @r   ra  ra  \  s    .KKMO2 2r   ra  ):loggingr   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.   django.views.decorators.debugr   r   	getLoggerr  r   Widgetr    FieldrI   rm   rV   re   r   	ModelFormr   r   r   Formr   r  r;  rJ  rS  ra  r;   r   r   <module>rx     sB      Q Q Q + > ; 2 3 " - 3 & , 6 =				0	1	 D* *
EOO 
(6 6rE EP&+U__ &R+ *U__ <N
 N
bd

 dNU&

 U.   F'68H%** 'T246F 2r   