aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth/Phone.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm14
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm14
3 files changed, 9 insertions, 27 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth/Phone.pm b/perllib/FixMyStreet/App/Controller/Auth/Phone.pm
index 6c6d7006e..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
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index fa3967bf3..5f36443c0 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1114,18 +1114,8 @@ sub send_problem_confirm_text : Private {
sub confirm_by_text : Path('text') {
my ( $self, $c ) = @_;
- my $token = $c->stash->{token} = $c->get_param('token');
- my $code = $c->get_param('code') || '';
-
- my $data = $c->stash->{token_data} = $c->forward('/auth/get_token', [ $token, 'problem' ]) || return;
- if ($data->{code} ne $code) {
- $c->stash->{template} = 'auth/smsform.html';
- $c->stash->{submit_url} = '/report/new/text';
- $c->stash->{incorrect_code} = 1;
- return;
- }
-
- $c->detach('process_confirmation');
+ $c->stash->{submit_url} = '/report/new/text';
+ $c->forward('/auth/phone/code', [ 'problem', '/report/new/process_confirmation' ]);
}
sub process_confirmation : Private {
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 66724f2d1..c28039808 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -521,18 +521,8 @@ sub send_confirmation_text : Private {
sub confirm_by_text : Path('text') {
my ( $self, $c ) = @_;
- my $token = $c->stash->{token} = $c->get_param('token');
- my $code = $c->get_param('code') || '';
-
- my $data = $c->stash->{token_data} = $c->forward('/auth/get_token', [ $token, 'comment' ]) || return;
- if ($data->{code} ne $code) {
- $c->stash->{template} = 'auth/smsform.html';
- $c->stash->{submit_url} = '/report/update/text';
- $c->stash->{incorrect_code} = 1;
- return;
- }
-
- $c->detach('process_confirmation');
+ $c->stash->{submit_url} = '/report/update/text';
+ $c->forward('/auth/phone/code', [ 'comment', '/report/update/process_confirmation' ]);
}
sub process_confirmation : Private {