Ticket #16919: setpasswordform_withtests.diff
File setpasswordform_withtests.diff, 2.4 KB (added by , 13 years ago) |
---|
-
django/contrib/auth/views.py
208 208 form.save() 209 209 return HttpResponseRedirect(post_reset_redirect) 210 210 else: 211 form = set_password_form( None)211 form = set_password_form(user) 212 212 else: 213 213 validlink = False 214 214 form = None -
django/contrib/auth/tests/views.py
180 180 self.assertEqual(response.status_code, 200) 181 181 self.assertContainsEscaped(response, SetPasswordForm.error_messages['password_mismatch']) 182 182 183 def test_confirm_display_user_from_form(self): 184 url, path = self._test_confirm_start() 185 response = self.client.get(path) 183 186 187 # The ``password_reset_confirm`` view should stash the user object 188 # on the ``SetPasswordForm`` object that it creates, even on GET requests. 189 # For this test suite, we render ``{{ form.user }}`` in the template 190 # ``registration/password_reset_confirm.html`` so that we can test this. 191 # See #16919. 192 username = User.objects.get(email='staffmember@example.com').username 193 self.assertTrue("Hello, %s." % username in response.content) 194 195 # However, the view should NOT stash any user object on a form if the 196 # password reset link was invalid. 197 response = self.client.get('/reset/zzzzzzzzzzzzz-1-1/') 198 self.assertTrue("Hello, ." in response.content) 199 184 200 class ChangePasswordTest(AuthViewsTestCase): 185 201 186 202 def fail_login(self, password='password'): -
django/contrib/auth/tests/templates/registration/password_reset_confirm.html
1 Hello, {{ form.user }}. 2 1 3 {% if validlink %} 2 4 Please enter your new password: {{ form }} 3 5 {% else %} … … 2 4 The password reset link was invalid 3 {% endif %} 4 No newline at end of file 5 {% endif %}