diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-06-26 16:51:25 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-06-26 16:51:25 +0000 |
| commit | 821d8aaaaad3f4d11f29eb54a7812f363b5f07cb (patch) | |
| tree | fb340a2d40f26196a8feb3f7a0709871d5c664b8 | |
| parent | 650739ef172049a294f53bf51b70f6bb2d3f5dd5 (diff) | |
Fixed #15266 -- Applied login_required decorator to password_change_done view. Thanks, lasko.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16454 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/auth/tests/views.py | 17 | ||||
| -rw-r--r-- | django/contrib/auth/views.py | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py index b03489c7d2..1011671fe6 100644 --- a/django/contrib/auth/tests/views.py +++ b/django/contrib/auth/tests/views.py @@ -193,6 +193,23 @@ class ChangePasswordTest(AuthViewsTestCase): self.fail_login() self.login(password='password1') + def test_password_change_done_succeeds(self): + self.login() + response = self.client.post('/password_change/', { + 'old_password': 'password', + 'new_password1': 'password1', + 'new_password2': 'password1', + } + ) + self.assertEqual(response.status_code, 302) + self.assertTrue(response['Location'].endswith('/password_change/done/')) + + def test_password_change_done_fails(self): + response = self.client.get('/password_change/done/') + self.assertEqual(response.status_code, 302) + self.assertTrue(response['Location'].endswith('/login/?next=/password_change/done/')) + + class LoginTest(AuthViewsTestCase): def test_current_site_in_context_after_login(self): diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 82759e9e4f..c86ef53595 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -257,6 +257,7 @@ def password_change(request, return TemplateResponse(request, template_name, context, current_app=current_app) +@login_required def password_change_done(request, template_name='registration/password_change_done.html', current_app=None, extra_context=None): |
