From f1624f57d1a7ee81f9ef64ce052926fd1879d8c1 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Mon, 29 Jan 2024 12:18:51 +0000 Subject: [PATCH] More accurate error message for incorrect password during reporting --- perllib/FixMyStreet/App/Controller/Report/New.pm | 1 + perllib/FixMyStreet/App/Controller/Report/Update.pm | 1 + t/app/controller/report_new_errors.t | 2 ++ t/app/controller/report_new_text.t | 1 + t/app/controller/report_update_text.t | 1 + t/app/controller/report_updates.t | 2 ++ templates/web/base/report/form/user_loggedout_password.html | 3 ++- 7 files changed, 10 insertions(+), 1 deletion(-) diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 66a4bf2d611..ddb0ba34c65 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -1058,6 +1058,7 @@ sub process_user : Private { }; unless ( $c->forward( '/auth/sign_in', [ $params{username} ] ) ) { $c->stash->{field_errors}->{password} = _('There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the ‘No’ section of the form.'); + $c->stash->{field_errors}->{password_js} = _('There was a problem with your login information. If you cannot remember your password, or do not have one, please select ‘Fill in your details manually’.'); return 1; } my $user = $c->user->obj; diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm index a27978733be..53367fdabd4 100644 --- a/perllib/FixMyStreet/App/Controller/Report/Update.pm +++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm @@ -163,6 +163,7 @@ sub process_user : Private { }; unless ( $c->forward( '/auth/sign_in', [ $params{username} ] ) ) { $c->stash->{field_errors}->{password} = _('There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the ‘No’ section of the form.'); + $c->stash->{field_errors}->{password_js} = _('There was a problem with your login information. If you cannot remember your password, or do not have one, please select ‘Fill in your details manually’.'); return 1; } my $user = $c->user->obj; diff --git a/t/app/controller/report_new_errors.t b/t/app/controller/report_new_errors.t index d0fa3be4c19..f942f099ebe 100644 --- a/t/app/controller/report_new_errors.t +++ b/t/app/controller/report_new_errors.t @@ -765,6 +765,7 @@ subtest "test password errors for a user who is signing in as they report" => su is_deeply $mech->page_errors, [ "Please enter a valid email", "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", ], "check there were errors"; $mech->submit_form_ok( @@ -786,6 +787,7 @@ subtest "test password errors for a user who is signing in as they report" => su # check that we got the errors expected is_deeply $mech->page_errors, [ "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", ], "check there were errors"; $mech->content_lacks('1234 567', 'phone number not shown'); diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index cdc685c97e8..ec981af1705 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -285,6 +285,7 @@ subtest "test password errors for a user who is signing in as they report" => su # check that we got the errors expected is_deeply $mech->page_errors, [ "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", ], "check there were errors"; $mech->content_lacks($user->email, 'email not displayed'); diff --git a/t/app/controller/report_update_text.t b/t/app/controller/report_update_text.t index fbf5ca0c64c..5694f1ef1c9 100644 --- a/t/app/controller/report_update_text.t +++ b/t/app/controller/report_update_text.t @@ -242,6 +242,7 @@ for my $test ( }, field_errors => [ "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", 'Please enter your name', # FIXME Not really necessary error ], }, diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 191f2179e5f..2e9e0321cbc 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -1240,6 +1240,7 @@ for my $test ( field_errors => [ 'Please enter a valid email', "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", 'Please enter your name', # FIXME Not really necessary error ], }, @@ -1254,6 +1255,7 @@ for my $test ( }, field_errors => [ "There was a problem with your login information. If you cannot remember your password, or do not have one, please fill in the \x{2018}No\x{2019} section of the form.", + "There was a problem with your login information. If you cannot remember your password, or do not have one, please select \x{2018}Fill in your details manually\x{2019}.", 'Please enter your name', # FIXME Not really necessary error ], }, diff --git a/templates/web/base/report/form/user_loggedout_password.html b/templates/web/base/report/form/user_loggedout_password.html index 4b8611fcbbb..384aab96da4 100644 --- a/templates/web/base/report/form/user_loggedout_password.html +++ b/templates/web/base/report/form/user_loggedout_password.html @@ -12,7 +12,8 @@

[% loc('Yes I have a password') %]

[% IF field_errors.password %] -

[% field_errors.password %]

+

[% field_errors.password %]

+

[% field_errors.password_js %]

[% END %]