summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2009-02-26 17:11:28 +0000
committerLuke Plant <L.Plant.98@cantab.net>2009-02-26 17:11:28 +0000
commit1306079a024ac7109487d2a560ceda3f842a4572 (patch)
tree662cfa7b8503abbf0247980cd0a6bee5c3936f6d
parent8ffe8981f6944219dabae16e900a5eb00c809316 (diff)
Fixed #10017 - PasswordResetForm.clean_email was not returning the value.
Thanks Zak Johnson, Leo git-svn-id: http://code.djangoproject.com/svn/django/trunk@9906 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/forms.py1
-rw-r--r--django/contrib/auth/tests/forms.py29
2 files changed, 30 insertions, 0 deletions
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 3f7b13d35a..55e770e553 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -107,6 +107,7 @@ class PasswordResetForm(forms.Form):
self.users_cache = User.objects.filter(email__iexact=email)
if len(self.users_cache) == 0:
raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
+ return email
def save(self, domain_override=None, email_template_name='registration/password_reset_email.html',
use_https=False, token_generator=default_token_generator):
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index 714cd4570d..482979c59e 100644
--- a/django/contrib/auth/tests/forms.py
+++ b/django/contrib/auth/tests/forms.py
@@ -190,4 +190,33 @@ True
False
>>> form['username'].errors
[u'This value must contain only letters, numbers and underscores.']
+
+
+### PasswordResetForm
+
+>>> from django.contrib.auth.forms import PasswordResetForm
+>>> data = {'email':'not valid'}
+>>> form = PasswordResetForm(data)
+>>> form.is_valid()
+False
+>>> form['email'].errors
+[u'Enter a valid e-mail address.']
+
+# Test nonexistant email address
+>>> data = {'email':'foo@bar.com'}
+>>> form = PasswordResetForm(data)
+>>> form.is_valid()
+False
+>>> form.errors
+{'email': [u"That e-mail address doesn't have an associated user account. Are you sure you've registered?"]}
+
+# Test cleaned_data bug fix
+>>> user = User.objects.create_user("jsmith3", "jsmith3@example.com", "test123")
+>>> data = {'email':'jsmith3@example.com'}
+>>> form = PasswordResetForm(data)
+>>> form.is_valid()
+True
+>>> form.cleaned_data['email']
+u'jsmith3@example.com'
+
"""