aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/New.pm
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-09-21 09:10:58 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-09-25 13:28:14 +0100
commit85a6b7df9bd0b1711637b39d5a63ed6434686b33 (patch)
tree3a96fd0c05bfc47a642b23317a01275b6a8ab173 /perllib/FixMyStreet/App/Controller/Report/New.pm
parenta38ecfbe4c5e5741f902eab498a83857500ea8cc (diff)
If text auth on, ask which method they wish to use
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index d6314dacf..8f3261853 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -844,7 +844,7 @@ sub process_user : Private {
# Extract all the params to a hash to make them easier to work with
my %params = map { $_ => $c->get_param($_) }
- ( 'email', 'name', 'phone', 'password_register', 'fms_extra_title' );
+ qw( email name phone password_register fms_extra_title update_method );
# Report form includes two username fields: #form_username_register and #form_username_sign_in
$params{username} = (first { $_ } $c->get_param_list('username')) || '';
@@ -898,6 +898,20 @@ sub process_user : Private {
$params{username} = $params{phone};
}
+ # Code to deal with SMS being switched on and so the user being asked to
+ # pick a method and no username field
+ if (!$params{username} && !$params{update_method}) {
+ $c->stash->{field_errors}->{update_method} = _('Please pick your update preference');
+ }
+ if (!$params{username} && $params{update_method}) {
+ if ($params{update_method} eq 'phone') {
+ $params{username} = $params{phone};
+ } else {
+ $params{username} = $params{email};
+ }
+ $c->stash->{update_method} = $params{update_method};
+ }
+
my $parsed = FixMyStreet::SMS->parse_username($params{username});
my $type = $parsed->{type} || 'email';
$type = 'email' unless FixMyStreet->config('SMS_AUTHENTICATION') || $c->stash->{contributing_as_another_user};
@@ -1235,6 +1249,7 @@ sub check_for_errors : Private {
# if using social login then we don't care about other errors
$c->stash->{is_social_user} = $c->get_param('social_sign_in') ? 1 : 0;
if ( $c->stash->{is_social_user} ) {
+ delete $field_errors{update_method};
delete $field_errors{name};
delete $field_errors{username};
}