diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Auth/Phone.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Auth/Phone.pm | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth/Phone.pm b/perllib/FixMyStreet/App/Controller/Auth/Phone.pm index e4ffc2205..8387b9d64 100644 --- a/perllib/FixMyStreet/App/Controller/Auth/Phone.pm +++ b/perllib/FixMyStreet/App/Controller/Auth/Phone.pm @@ -23,17 +23,19 @@ Handle the submission of a code sent by text to a mobile number. =cut sub code : Path('') { - my ( $self, $c ) = @_; + my ( $self, $c, $scope, $success_action ) = @_; $c->stash->{template} = 'auth/smsform.html'; + $scope ||= 'phone_sign_in'; + $success_action ||= '/auth/process_login'; my $token = $c->stash->{token} = $c->get_param('token'); my $code = $c->get_param('code') || ''; - my $data = $c->forward('/auth/get_token', [ $token, 'phone_sign_in' ]) || return; + my $data = $c->stash->{token_data} = $c->forward('/auth/get_token', [ $token, $scope ]) || return; $c->stash->{incorrect_code} = 1, return if $data->{code} ne $code; - $c->detach( '/auth/process_login', [ $data, 'phone' ] ); + $c->detach( $success_action, [ $data, 'phone' ] ); } =head2 sign_in @@ -90,6 +92,12 @@ sub send_token : Private { my ( $self, $c, $token_data, $token_scope, $to ) = @_; my $result = FixMyStreet::SMS->send_token($token_data, $token_scope, $to); + if ($result->{error}) { + $c->log->debug("Failure sending text containing code *$result->{random}*"); + $c->stash->{sms_error} = $result->{error}; + $c->stash->{username_error} = 'sms_failed'; + return; + } $c->stash->{token} = $result->{token}; $c->log->debug("Sending text containing code *$result->{random}*"); $c->stash->{template} = 'auth/smsform.html'; |