Fixed #26960 -- Added PasswordResetConfirmView option to automatically log in after a reset.

This commit is contained in:
jordij 2016-07-28 10:33:07 +12:00 committed by Tim Graham
parent 975a76a964
commit 0814566bf1
6 changed files with 23 additions and 1 deletions

View file

@ -307,6 +307,14 @@ class PasswordResetTest(AuthViewsTestCase):
self.assertEqual(response.status_code, 302)
self.assertURLEqual(response.url, '/password_reset/')
def test_confirm_login_post_reset(self):
url, path = self._test_confirm_start()
path = path.replace('/reset/', '/reset/post_reset_login/')
response = self.client.post(path, {'new_password1': 'anewpassword', 'new_password2': 'anewpassword'})
self.assertEqual(response.status_code, 302)
self.assertURLEqual(response.url, '/reset/done/')
self.assertIn(SESSION_KEY, self.client.session)
def test_confirm_display_user_from_form(self):
url, path = self._test_confirm_start()
response = self.client.get(path)

View file

@ -85,6 +85,8 @@ urlpatterns = auth_urlpatterns + [
views.PasswordResetConfirmView.as_view(success_url='/custom/')),
url(r'^reset/custom/named/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.PasswordResetConfirmView.as_view(success_url=reverse_lazy('password_reset'))),
url(r'^reset/post_reset_login/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
views.PasswordResetConfirmView.as_view(post_reset_login=True)),
url(r'^password_change/custom/$',
views.PasswordChangeView.as_view(success_url='/custom/')),
url(r'^password_change/custom/named/$',