Skip to content

Commit

Permalink
More accurate error message for incorrect password during reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
davea committed Jan 31, 2024
1 parent f997ae1 commit f1624f5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions perllib/FixMyStreet/App/Controller/Report/New.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions perllib/FixMyStreet/App/Controller/Report/Update.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions t/app/controller/report_new_errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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');
Expand Down
1 change: 1 addition & 0 deletions t/app/controller/report_new_text.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions t/app/controller/report_update_text.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
},
Expand Down
2 changes: 2 additions & 0 deletions t/app/controller/report_updates.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
},
Expand All @@ -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
],
},
Expand Down
3 changes: 2 additions & 1 deletion templates/web/base/report/form/user_loggedout_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ <h3 class="hidden-js">[% loc('<strong>Yes</strong> I have a password') %]</h3>

<label for="password_sign_in">[% loc('Your password') %]</label>
[% IF field_errors.password %]
<p class='form-error'>[% field_errors.password %]</p>
<p class='form-error hidden-js'>[% field_errors.password %]</p>
<p class='form-error hidden-nojs'>[% field_errors.password_js %]</p>
[% END %]
<input class="form-control" type="password" name="password_sign_in" id="password_sign_in" value="">

Expand Down

0 comments on commit f1624f5

Please sign in to comment.