aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-01-29 08:28:36 +0000
committerDave Arter <davea@mysociety.org>2018-02-07 17:22:10 +0000
commit01311af63412f39b75ff3b12bb6dc4051eab13b3 (patch)
treef612e211382ed2523e5fe65716722fa30ea9a7b7 /perllib/FixMyStreet/App/Controller
parentd1f04a07b1eb2f24a065a26320350977a10b400f (diff)
Allow ‘report as another user’ to only provide a phone number
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 85652450e..eff45013f 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -790,12 +790,20 @@ sub process_user : Private {
return 1;
} }
+ if ( $c->stash->{contributing_as_another_user} && !$params{username} ) {
+ # If the 'username' (i.e. email) field is blank, then use the phone
+ # field for the username.
+ $params{username} = $params{phone};
+ }
+
my $parsed = FixMyStreet::SMS->parse_username($params{username});
my $type = $parsed->{type} || 'email';
- $type = 'email' unless FixMyStreet->config('SMS_AUTHENTICATION');
+ $type = 'email' unless FixMyStreet->config('SMS_AUTHENTICATION') || $c->stash->{contributing_as_another_user};
$report->user( $c->model('DB::User')->find_or_new( { $type => $parsed->{username} } ) )
unless $report->user;
+ $c->stash->{phone_may_be_mobile} = $type eq 'phone' && $parsed->{may_be_mobile};
+
# The user is trying to sign in. We only care about username from the params.
if ( $c->get_param('submit_sign_in') || $c->get_param('password_sign_in') ) {
$c->stash->{tfa_data} = {
@@ -1076,6 +1084,12 @@ sub check_for_errors : Private {
delete $field_errors{username};
}
+ # if we're contributing as someone else then allow landline numbers
+ if ( $field_errors{phone} && $c->stash->{contributing_as_another_user} && !$c->stash->{phone_may_be_mobile}) {
+ delete $field_errors{username};
+ delete $field_errors{phone};
+ }
+
# add the photo error if there is one.
if ( my $photo_error = delete $c->stash->{photo_error} ) {
$field_errors{photo} = $photo_error;
@@ -1384,7 +1398,7 @@ sub redirect_or_confirm_creation : Private {
if ( $report->confirmed ) {
# Subscribe problem reporter to email updates
$c->forward( 'create_reporter_alert' );
- if ($c->stash->{contributing_as_another_user}) {
+ if ($c->stash->{contributing_as_another_user} && $report->user->email) {
$c->send_email( 'other-reported.txt', {
to => [ [ $report->user->email, $report->name ] ],
} );