summaryrefslogtreecommitdiff
path: root/django/contrib/auth/forms.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-08-04 14:55:13 +0200
committerClaude Paroz <claude@2xlibre.net>2012-08-04 14:55:13 +0200
commit09a719a4e6820d462fc796606cb242583ad4e79d (patch)
tree460b698db7f8d3274a16b3baf67467a4a74b7ed4 /django/contrib/auth/forms.py
parent121fd109de09ece4e263e508f9034df9b583da46 (diff)
Fixed #7833 -- Improved UserCreationForm password validation
Make UserCreationForm password validation similar to SetPasswordForm and AdminPasswordChangeForm, so as the match check is only done when both passwords are supplied. Thanks Mitar for the suggestion.
Diffstat (limited to 'django/contrib/auth/forms.py')
-rw-r--r--django/contrib/auth/forms.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index d17c41132e..dfd039f018 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -89,9 +89,9 @@ class UserCreationForm(forms.ModelForm):
raise forms.ValidationError(self.error_messages['duplicate_username'])
def clean_password2(self):
- password1 = self.cleaned_data.get("password1", "")
- password2 = self.cleaned_data["password2"]
- if password1 != password2:
+ password1 = self.cleaned_data.get("password1")
+ password2 = self.cleaned_data.get("password2")
+ if password1 and password2 and password1 != password2:
raise forms.ValidationError(
self.error_messages['password_mismatch'])
return password2