-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Fixed #28127 -- Allowed UserCreationForm's password validation to check all user fields. #8408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
django/contrib/auth/forms.py
Outdated
try: | ||
password_validation.validate_password(password, self.instance) | ||
except forms.ValidationError as error: | ||
self.add_error("password2", error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use single quotes.
django/contrib/auth/forms.py
Outdated
return password2 | ||
|
||
def _post_clean(self): | ||
super()._post_clean() # creates self.instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the comment, I'd say # updates self.instance with form data
(since self.instance
is first assigned in ModelForm.init()` "creates" might be confusing)
django/contrib/auth/forms.py
Outdated
return password2 | ||
|
||
def _post_clean(self): | ||
super()._post_clean() # creates self.instance | ||
password = self.cleaned_data.get("password2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use single quotes.
docs/releases/2.0.txt
Outdated
@@ -54,6 +54,10 @@ Minor features | |||
* The default iteration count for the PBKDF2 password hasher is increased from | |||
36,000 to 100,000. | |||
|
|||
* The :class:`~django.contrib.auth.forms.UserCreationForm` and subclasses will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider this a bug fix rather than a minor feature so no release note is needed.
tests/auth_tests/test_forms.py
Outdated
@@ -872,3 +872,118 @@ def test_password_whitespace_not_stripped(self): | |||
self.assertTrue(form.is_valid()) | |||
self.assertEqual(form.cleaned_data['password1'], data['password1']) | |||
self.assertEqual(form.cleaned_data['password2'], data['password2']) | |||
|
|||
|
|||
@override_settings(AUTH_PASSWORD_VALIDATORS=[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's enough to include a single test in UserCreationFormTest
. Testing for both first_name and last_name seem unnecessary.
Adding tests for PasswordChangeForm that aren't affected by this change shouldn't be done in this commit.
Hi Tim, Changes made! I think this is good to go. Please let me know if I misunderstood any of your instructions. |
…ck all user fields.
checking all fields in the form, not just the username