diff --git a/src/authentic2/forms/passwords.py b/src/authentic2/forms/passwords.py index 052203e5d..9c04053bc 100644 --- a/src/authentic2/forms/passwords.py +++ b/src/authentic2/forms/passwords.py @@ -127,7 +127,12 @@ class PasswordResetForm(HoneypotForm): logger.info('password reset request for "%s", no user found', email) if getattr(settings, 'REGISTRATION_OPEN', True): ctx = { - 'registration_url': utils_misc.make_url('registration_register', absolute=True), + 'registration_url': utils_misc.make_url( + 'registration_register', + absolute=True, + next_url=self.cleaned_data.get('next_url'), + sign_next_url=True, + ), } else: ctx = {} diff --git a/tests/test_password_reset.py b/tests/test_password_reset.py index c7d7202a8..e0646616c 100644 --- a/tests/test_password_reset.py +++ b/tests/test_password_reset.py @@ -167,8 +167,7 @@ def test_old_url_redirect(app): ) def test_send_password_reset_email_no_account(app, db, mailoutbox, settings, registration_open): settings.REGISTRATION_OPEN = registration_open - url = reverse('password_reset') - resp = app.get(url, status=200) + resp = app.get('/password/reset/?next=/whatever/', status=200) resp.form.set('email', 'test@entrouvert.com') resp = resp.form.submit() @@ -178,6 +177,8 @@ def test_send_password_reset_email_no_account(app, db, mailoutbox, settings, reg assert 'no account was found associated with this address' in body if settings.REGISTRATION_OPEN: assert 'http://testserver/register/' in body + # check next_url was preserved + assert 'next=/whatever/' in body else: assert 'http://testserver/register/' not in body