mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-16 08:24:28 -05:00
Turn on redirects for email_not_received
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:
@@ -49,7 +49,8 @@ def check_and_resend_verification_code():
|
||||
@main.route('/email-not-received', methods=['GET'])
|
||||
@redirect_to_sign_in
|
||||
def email_not_received():
|
||||
return render_template('views/email-not-received.html')
|
||||
redirect_url = request.args.get('next')
|
||||
return render_template('views/email-not-received.html', redirect_url=redirect_url)
|
||||
|
||||
|
||||
@main.route('/send-new-email-token', methods=['GET'])
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
{{ govukButton({
|
||||
"element": "a",
|
||||
"text": "Resend email link",
|
||||
"href": url_for('main.resend_email_link')
|
||||
"href": url_for('main.resend_email_link', next=redirect_url)
|
||||
}) }}
|
||||
</p>
|
||||
|
||||
|
||||
@@ -176,3 +176,28 @@ def test_redirect_to_sign_in_if_not_logged_in(
|
||||
|
||||
assert response.location == url_for('main.sign_in', _external=True)
|
||||
assert response.status_code == 302
|
||||
|
||||
|
||||
@pytest.mark.parametrize('redirect_url', [
|
||||
None,
|
||||
'blob',
|
||||
])
|
||||
def test_should_render_correct_email_not_received_template_for_active_user(
|
||||
client,
|
||||
api_user_active,
|
||||
mock_get_user_by_email,
|
||||
mock_send_verify_code,
|
||||
redirect_url
|
||||
):
|
||||
with client.session_transaction() as session:
|
||||
session['user_details'] = {
|
||||
'id': api_user_active['id'],
|
||||
'email': api_user_active['email_address']}
|
||||
response = client.get(url_for('main.email_not_received', next=redirect_url))
|
||||
assert response.status_code == 200
|
||||
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
assert page.h1.string == 'Resend email link'
|
||||
# there shouldn't be a form for updating mobile number
|
||||
assert page.find('form') is None
|
||||
assert page.find('a', class_="govuk-button")['href'] == url_for('main.resend_email_link', next=redirect_url)
|
||||
|
||||
Reference in New Issue
Block a user