Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #10017 - PasswordResetForm.clean_email was not returnin…

…g the value.

Thanks Zak Johnson, Leo

Backport of r9906 from trunk.



git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9907 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f799959008b95f0e770ab35096de5b86659a962d 1 parent c9a6388
Luke Plant authored February 26, 2009
1  django/contrib/auth/forms.py
@@ -107,6 +107,7 @@ def clean_email(self):
107 107
         self.users_cache = User.objects.filter(email__iexact=email)
108 108
         if len(self.users_cache) == 0:
109 109
             raise forms.ValidationError(_("That e-mail address doesn't have an associated user account. Are you sure you've registered?"))
  110
+        return email
110 111
 
111 112
     def save(self, domain_override=None, email_template_name='registration/password_reset_email.html',
112 113
              use_https=False, token_generator=default_token_generator):
29  django/contrib/auth/tests/forms.py
@@ -190,4 +190,33 @@
190 190
 False
191 191
 >>> form['username'].errors
192 192
 [u'This value must contain only letters, numbers and underscores.']
  193
+
  194
+
  195
+### PasswordResetForm
  196
+
  197
+>>> from django.contrib.auth.forms import PasswordResetForm
  198
+>>> data = {'email':'not valid'}
  199
+>>> form = PasswordResetForm(data)
  200
+>>> form.is_valid()
  201
+False
  202
+>>> form['email'].errors
  203
+[u'Enter a valid e-mail address.']
  204
+
  205
+# Test nonexistant email address
  206
+>>> data = {'email':'foo@bar.com'}
  207
+>>> form = PasswordResetForm(data)
  208
+>>> form.is_valid()
  209
+False
  210
+>>> form.errors
  211
+{'email': [u"That e-mail address doesn't have an associated user account. Are you sure you've registered?"]}
  212
+
  213
+# Test cleaned_data bug fix
  214
+>>> user = User.objects.create_user("jsmith3", "jsmith3@example.com", "test123")
  215
+>>> data = {'email':'jsmith3@example.com'}
  216
+>>> form = PasswordResetForm(data)
  217
+>>> form.is_valid()
  218
+True
  219
+>>> form.cleaned_data['email']
  220
+u'jsmith3@example.com'
  221
+
193 222
 """

0 notes on commit f799959

Please sign in to comment.
Something went wrong with that request. Please try again.