Turn on redirects revalidate_email_sent

This is part of the work to make sure user is redirected
to the page they initially were meant to visit after
they sign in.
This commit is contained in:
Pea Tyczynska
2020-10-09 11:42:46 +01:00
parent 44ddee23ac
commit 2203fae195
3 changed files with 8 additions and 8 deletions

View File

@@ -85,7 +85,8 @@ def two_factor():
@main.route('/re-validate-email', methods=['GET'])
def revalidate_email_sent():
title = 'Email resent' if request.args.get('email_resent') else 'Check your email'
return render_template('views/re-validate-email-sent.html', title=title)
redirect_url = request.args.get('next')
return render_template('views/re-validate-email-sent.html', title=title, redirect_url=redirect_url)
# see http://flask.pocoo.org/snippets/62/

View File

@@ -14,7 +14,7 @@
<p class="govuk-body">Weve sent you a link to sign in to Notify. The link will open in a new browser window, so you can close this one.</p>
{{ page_footer(
secondary_link=url_for('main.email_not_received'),
secondary_link=url_for('main.email_not_received', next=redirect_url),
secondary_link_text='Not received an email?'
) }}
</div>

View File

@@ -11,10 +11,8 @@ from tests.conftest import (
)
@pytest.mark.parametrize('redirect_url', [
None,
'blob',
])
@pytest.mark.parametrize('request_url', ['two_factor_email_sent', 'revalidate_email_sent'])
@pytest.mark.parametrize('redirect_url', [None, 'blob'])
@pytest.mark.parametrize('email_resent, page_title', [
(None, 'Check your email'),
(True, 'Email resent')
@@ -23,9 +21,10 @@ def test_two_factor_email_sent_page(
client,
email_resent,
page_title,
redirect_url
redirect_url,
request_url
):
response = client.get(url_for('main.two_factor_email_sent', next=redirect_url, email_resent=email_resent))
response = client.get(url_for(f'main.{request_url}', next=redirect_url, email_resent=email_resent))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')