diff options
| author | Fabian Braun <fsbraun@gmx.de> | 2024-05-28 08:15:12 +0200 |
|---|---|---|
| committer | Natalia <124304+nessita@users.noreply.github.com> | 2024-05-30 16:31:52 -0300 |
| commit | 9996bb1eadc108d228a20d928bccae84afd338d6 (patch) | |
| tree | 830c6eca11945c20dc8c6f8e704975133a68af4a /django | |
| parent | f0d592ed34a723998f83fa53ee4578e1c7dfbfc5 (diff) | |
[5.1.x] Fixed #35477 -- Corrected 'required' errors in auth password set/change forms.
The auth forms using SetPasswordMixin were incorrectly including the
'This field is required.' error when additional validations (e.g.,
overriding `clean_password1`) were performed and failed.
This fix ensures accurate error reporting for password fields.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
Backport of 339977d4441fd353e20950b98bad3d42afb1f126 from main.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/auth/forms.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index ab46caa12e..31e96ff91c 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -154,14 +154,14 @@ class SetPasswordMixin: if not usable_password: return self.cleaned_data - if not password1: + if not password1 and password1_field_name not in self.errors: error = ValidationError( self.fields[password1_field_name].error_messages["required"], code="required", ) self.add_error(password1_field_name, error) - if not password2: + if not password2 and password2_field_name not in self.errors: error = ValidationError( self.fields[password2_field_name].error_messages["required"], code="required", |
