From db2d312ba753713675a12efd39de95e8513f91e7 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 26 Mar 2020 12:41:46 +0000 Subject: [PATCH] =?UTF-8?q?Link=20to=20=E2=80=98who=20it=E2=80=99s=20for?= =?UTF-8?q?=E2=80=99=20when=20error=20creating=20account?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- app/main/validators.py | 9 +++---- app/templates/views/register.html | 2 +- tests/app/main/test_validators.py | 2 +- tests/app/main/views/test_manage_users.py | 2 +- tests/app/main/views/test_register.py | 30 ++++++++++++++--------- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/main/validators.py b/app/main/validators.py index 39bf2fb0b..f35d6208a 100644 --- a/app/main/validators.py +++ b/app/main/validators.py @@ -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' - ' contact us' - ).format(url_for('main.support')) + message = ''' + Enter a public sector email address or + find out who can use Notify + '''.format(url_for('main.who_its_for')) if not is_gov_user(field.data.lower()): raise ValidationError(message) diff --git a/app/templates/views/register.html b/app/templates/views/register.html index 71611a4ae..dfcf141bf 100644 --- a/app/templates/views/register.html +++ b/app/templates/views/register.html @@ -14,7 +14,7 @@ Create an account

Create an account

{% 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') }}
{{ textbox(form.mobile_number, width='3-4', hint='We’ll send you a security code by text message') }}
diff --git a/tests/app/main/test_validators.py b/tests/app/main/test_validators.py index cb3a0b375..1aaeaa01d 100644 --- a/tests/app/main/test_validators.py +++ b/tests/app/main/test_validators.py @@ -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( diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 9832d4c12..36095e59b 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -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 diff --git a/tests/app/main/views/test_register.py b/tests/app/main/views/test_register.py index fdb4a4e6f..6cf7a8c16 100644 --- a/tests/app/main/views/test_register.py +++ b/tests/app/main/views/test_register.py @@ -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', (