diff options
-rwxr-xr-x | perllib/FixMyStreet/App/Controller/Questionnaire.pm | 23 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Tokens.pm | 14 |
2 files changed, 20 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index 19d057958..0126fe566 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -19,24 +19,17 @@ Deals with report questionnaires. =cut -=head2 load_questionnaire +=head2 check_questionnaire -Loads the questionnaire from the database, and checks it still needs answering -and is in the right state. Also finds out if this user has answered the -"ever reported" question before. +Checks the questionnaire still needs answering and is in the right state. Also +finds out if this user has answered the "ever reported" question before. =cut -sub load_questionnaire : Private { +sub check_questionnaire : Private { my ( $self, $c ) = @_; - my $questionnaire = $c->model('DB::Questionnaire')->find( - { id => $c->stash->{id} }, - { prefetch => 'problem' } - ); - $c->detach('missing_problem') unless $questionnaire; - - $c->stash->{questionnaire} = $questionnaire; + my $questionnaire = $c->stash->{questionnaire}; my $problem_id = $questionnaire->problem_id; @@ -149,8 +142,8 @@ sub submit_creator_fixed : Private { sub submit_standard : Private { my ( $self, $c ) = @_; - $c->forward( '/tokens/load_questionnaire_id', [ $c->req->params->{token} ] ); - $c->forward( 'load_questionnaire' ); + $c->forward( '/tokens/load_questionnaire', [ $c->req->params->{token} ] ); + $c->forward( 'check_questionnaire' ); $c->forward( 'process_questionnaire' ); my $problem = $c->stash->{problem}; @@ -261,7 +254,7 @@ sub process_questionnaire : Private { # Sent here from email token action. Simply load and display questionnaire. sub index : Private { my ( $self, $c ) = @_; - $c->forward( 'load_questionnaire' ); + $c->forward( 'check_questionnaire' ); $c->forward( 'display' ); } diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm index c9c9f3ab7..1fef0f07e 100644 --- a/perllib/FixMyStreet/App/Controller/Tokens.pm +++ b/perllib/FixMyStreet/App/Controller/Tokens.pm @@ -154,7 +154,7 @@ sub confirm_update : Path('/C') { return 1; } -sub load_questionnaire_id : Private { +sub load_questionnaire : Private { my ( $self, $c, $token_code ) = @_; # Set up error handling @@ -164,11 +164,21 @@ sub load_questionnaire_id : Private { my $auth_token = $c->forward( 'load_auth_token', [ $token_code, 'questionnaire' ] ); $c->stash->{id} = $auth_token->data; $c->stash->{token} = $token_code; + + my $questionnaire = $c->model('DB::Questionnaire')->find( + { id => $c->stash->{id} }, + { prefetch => 'problem' } + ); + $c->detach('/questionnaire/missing_problem') unless $questionnaire; + $c->stash->{questionnaire} = $questionnaire; } sub questionnaire : Path('/Q') : Args(1) { my ( $self, $c, $token_code ) = @_; - $c->forward( 'load_questionnaire_id', [ $token_code ] ); + $c->forward( 'load_questionnaire', [ $token_code ] ); + + $c->authenticate( { email => $c->stash->{questionnaire}->problem->user->email }, 'no_password' ); + $c->set_session_cookie_expire(0); $c->forward( '/questionnaire/index'); } |