Projet

Général

Profil

0001-views-keep-next_url-on-password-reset-69537.patch

Benjamin Dauvergne, 29 septembre 2022 12:56

Télécharger (2,35 ko)

Voir les différences:

Subject: [PATCH] views: keep next_url on password reset (#69537)

It was already working in the regular case, but not if no account
matches the given email.
 src/authentic2/forms/passwords.py | 7 ++++++-
 tests/test_password_reset.py      | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)
src/authentic2/forms/passwords.py
127 127
            logger.info('password reset request for "%s", no user found', email)
128 128
            if getattr(settings, 'REGISTRATION_OPEN', True):
129 129
                ctx = {
130
                    'registration_url': utils_misc.make_url('registration_register', absolute=True),
130
                    'registration_url': utils_misc.make_url(
131
                        'registration_register',
132
                        absolute=True,
133
                        next_url=self.cleaned_data.get('next_url'),
134
                        sign_next_url=True,
135
                    ),
131 136
                }
132 137
            else:
133 138
                ctx = {}
tests/test_password_reset.py
167 167
)
168 168
def test_send_password_reset_email_no_account(app, db, mailoutbox, settings, registration_open):
169 169
    settings.REGISTRATION_OPEN = registration_open
170
    url = reverse('password_reset')
171
    resp = app.get(url, status=200)
170
    resp = app.get('/password/reset/?next=/whatever/', status=200)
172 171
    resp.form.set('email', 'test@entrouvert.com')
173 172
    resp = resp.form.submit()
174 173

  
......
178 177
        assert 'no account was found associated with this address' in body
179 178
        if settings.REGISTRATION_OPEN:
180 179
            assert 'http://testserver/register/' in body
180
            # check next_url was preserved
181
            assert 'next=/whatever/' in body
181 182
        else:
182 183
            assert 'http://testserver/register/' not in body
183 184

  
184
-