mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-18 13:39:57 -04:00
Turn on redirects for two_factor_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:
@@ -24,7 +24,8 @@ def two_factor_email_sent():
|
||||
title = 'Email resent' if request.args.get('email_resent') else 'Check your email'
|
||||
return render_template(
|
||||
'views/two-factor-email.html',
|
||||
title=title
|
||||
title=title,
|
||||
redirect_url=request.args.get('next')
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<p class="govuk-body">We’ve emailed you a link to sign in to Notify.</p>
|
||||
<p class="govuk-body">Clicking the link will open Notify 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>
|
||||
|
||||
@@ -11,6 +11,32 @@ from tests.conftest import (
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('redirect_url', [
|
||||
None,
|
||||
'blob',
|
||||
])
|
||||
@pytest.mark.parametrize('email_resent, page_title', [
|
||||
(None, 'Check your email'),
|
||||
(True, 'Email resent')
|
||||
])
|
||||
def test_two_factor_email_sent_page(
|
||||
client,
|
||||
email_resent,
|
||||
page_title,
|
||||
redirect_url
|
||||
):
|
||||
response = client.get(url_for('main.two_factor_email_sent', next=redirect_url, email_resent=email_resent))
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.h1.string == page_title
|
||||
# there shouldn't be a form for updating mobile number
|
||||
assert page.find('form') is None
|
||||
resend_email_link = page.find('a', class_="govuk-link govuk-link--no-visited-state page-footer-secondary-link")
|
||||
assert resend_email_link.text == 'Not received an email?'
|
||||
assert resend_email_link['href'] == url_for('main.email_not_received', next=redirect_url)
|
||||
|
||||
|
||||
def test_should_render_two_factor_page(
|
||||
client,
|
||||
api_user_active,
|
||||
|
||||
Reference in New Issue
Block a user