diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 18 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 4 | ||||
-rw-r--r-- | perllib/FixMyStreet/Script/Reports.pm | 4 |
3 files changed, 20 insertions, 6 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 ] ], } ); diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index a6b927ad1..db68236bf 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -200,9 +200,13 @@ sub check_for_errors { } elsif ($self->phone_verified) { my $parsed = FixMyStreet::SMS->parse_username($self->phone); if (!$parsed->{phone}) { + # Errors with the phone number may apply to both the username or + # phone field depending on the form. $errors{username} = _('Please check your phone number is correct'); + $errors{phone} = _('Please check your phone number is correct'); } elsif (!$parsed->{may_be_mobile}) { $errors{username} = _('Please enter a mobile number'); + $errors{phone} = _('Please enter a mobile number'); } } diff --git a/perllib/FixMyStreet/Script/Reports.pm b/perllib/FixMyStreet/Script/Reports.pm index 7e14fbb1e..d6a614651 100644 --- a/perllib/FixMyStreet/Script/Reports.pm +++ b/perllib/FixMyStreet/Script/Reports.pm @@ -106,10 +106,6 @@ sub send(;$) { $row->user->email eq $cobrand->anonymous_account->{'email'} ) { $h{anonymous_report} = 1; - $h{user_details} = _('This report was submitted anonymously'); - } else { - $h{user_details} = sprintf(_('Name: %s'), $row->name) . "\n\n"; - $h{user_details} .= sprintf(_('Email: %s'), $row->user->email) . "\n\n"; } $cobrand->call_hook(process_additional_metadata_for_email => $row, \%h); |