Link to ‘who it’s for’ when error creating account

If someone enters an email address from a domain we don’t recognise we
direct them straight to our support channel. This is causing increased
contact from suppliers and members of the public.

Now that we have a page which explains who can use Notify, let’s direct
people there first. Then if they really do need to contact support
(because we don’t recognise their organisation) then they can do so from
that page.
This commit is contained in:
Chris Hill-Scott
2020-03-26 12:41:46 +00:00
parent 41dd7a883b
commit db2d312ba7
5 changed files with 26 additions and 19 deletions

View File

@@ -43,11 +43,10 @@ class ValidGovEmail:
return
from flask import url_for
message = (
'Enter a government email address.'
' If you think you should have access'
' <a class="govuk-link govuk-link--no-visited-state" href="{}">contact us</a>'
).format(url_for('main.support'))
message = '''
Enter a public sector email address or
<a class="govuk-link govuk-link--no-visited-state" href="{}">find out who can use Notify</a>
'''.format(url_for('main.who_its_for'))
if not is_gov_user(field.data.lower()):
raise ValidationError(message)

View File

@@ -14,7 +14,7 @@ Create an account
<h1 class="heading-large">Create an account</h1>
{% call form_wrapper(autocomplete=True) %}
{{ textbox(form.name, width='3-4') }}
{{ textbox(form.email_address, hint="Must be from a government organisation", width='3-4', safe_error_message=True, autocomplete='email') }}
{{ textbox(form.email_address, hint="Must be from a public sector organisation", width='3-4', safe_error_message=True, autocomplete='email') }}
<div class="extra-tracking">
{{ textbox(form.mobile_number, width='3-4', hint='Well send you a security code by text message') }}
</div>

View File

@@ -36,7 +36,7 @@ def test_valid_email_not_in_valid_domains(
):
form = RegisterUserForm(email_address="test@test.com", mobile_number='441231231231')
assert not form.validate()
assert "Enter a government email address" in form.errors['email_address'][0]
assert "Enter a public sector email address" in form.errors['email_address'][0]
def test_valid_email_in_valid_domains(

View File

@@ -1192,7 +1192,7 @@ def test_edit_user_email_cannot_change_a_gov_email_address_to_a_non_gov_email_ad
},
_expected_status=200,
)
assert 'Enter a government email address.' in page.find('span', class_='error-message').text
assert 'Enter a public sector email address' in page.select_one('.error-message').text
with client_request.session_transaction() as session:
assert 'team_member_email_change-'.format(active_user_with_permissions['id']) not in session

View File

@@ -7,6 +7,7 @@ from flask import session, url_for
from flask_login import current_user
from app.models.user import InvitedUser
from tests.conftest import normalize_spaces
def test_render_register_returns_template_with_form(client):
@@ -97,20 +98,27 @@ def test_process_register_returns_200_when_mobile_number_is_invalid(
def test_should_return_200_when_email_is_not_gov_uk(
client,
mock_send_verify_code,
mock_get_user_by_email,
client_request,
mock_get_organisations,
mock_login,
):
response = client.post(url_for('main.register'),
data={'name': 'Bad Mobile',
'email_address': 'bad_mobile@example.not.right',
'mobile_number': '+44123412345',
'password': 'validPassword!'})
client_request.logout()
page = client_request.post(
'main.register',
_data={
'name': 'Firstname Lastname',
'email_address': 'bad_mobile@example.not.right',
'mobile_number': '07900900123',
'password': 'validPassword!'
},
_expected_status=200,
)
assert response.status_code == 200
assert 'Enter a government email address' in response.get_data(as_text=True)
assert normalize_spaces(page.select_one('.error-message').text) == (
'Enter a public sector email address or find out who can use Notify'
)
assert page.select_one('.error-message a')['href'] == url_for(
'main.who_its_for'
)
@pytest.mark.parametrize('email_address', (