aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth.pm3
-rwxr-xr-xperllib/FixMyStreet/App/Controller/JS.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm76
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm7
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm4
-rw-r--r--perllib/FixMyStreet/App/View/Web.pm3
7 files changed, 47 insertions, 49 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index b8f038ce3..f8ea84d08 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -195,6 +195,7 @@ sub display_location : Private {
colour => $colour,
id => $p->id,
title => $p->title_safe,
+ problem => $p,
}
} @$on_map_all, @$around_map;
}
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index b564a988c..ca4a2fc80 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -85,6 +85,9 @@ sub sign_in : Private {
$c->set_session_cookie_expire(0)
unless $remember_me;
+ # Regenerate CSRF token as session ID changed
+ $c->forward('get_csrf_token');
+
return 1;
}
diff --git a/perllib/FixMyStreet/App/Controller/JS.pm b/perllib/FixMyStreet/App/Controller/JS.pm
index 483c3c2cc..1ced9d43b 100755
--- a/perllib/FixMyStreet/App/Controller/JS.pm
+++ b/perllib/FixMyStreet/App/Controller/JS.pm
@@ -24,8 +24,6 @@ sub translation_strings : LocalRegex('^translation_strings\.(.*?)\.js$') : Args(
$c->res->content_type( 'application/javascript' );
}
-sub validation_rules : Path('validation_rules.js') : Args(0) { }
-
__PACKAGE__->meta->make_immutable;
1;
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 9779a5e2a..e81dc719f 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -143,22 +143,11 @@ sub report_new_ajax : Path('mobile') : Args(0) {
$c->forward('save_user_and_report');
my $report = $c->stash->{report};
- my $data = $c->stash->{token_data} || {};
- my $token = $c->model("DB::Token")->create( {
- scope => 'problem',
- data => {
- %$data,
- id => $report->id
- }
- } );
if ( $report->confirmed ) {
$c->forward( 'create_reporter_alert' );
$c->stash->{ json_response } = { success => 1, report => $report->id };
} else {
- $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
- $c->send_email( 'problem-confirm.txt', {
- to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ],
- } );
+ $c->forward( 'send_problem_confirm_email' );
$c->stash->{ json_response } = { success => 1 };
}
@@ -602,12 +591,12 @@ sub setup_categories_and_bodies : Private {
my %bodies = map { $_->id => $_ } @bodies;
my $first_body = ( values %bodies )[0];
- my @contacts #
+ my $contacts #
= $c #
->model('DB::Contact') #
->not_deleted #
- ->search( { body_id => [ keys %bodies ] } )
- ->all;
+ ->search( { body_id => [ keys %bodies ] } );
+ my @contacts = $c->cobrand->categories_restriction($contacts)->all;
# variables to populate
my %bodies_to_list = (); # Bodies with categories assigned
@@ -670,15 +659,6 @@ sub setup_categories_and_bodies : Private {
$c->cobrand->munge_category_list(\@category_options, \@contacts, \%category_extras)
if $c->cobrand->can('munge_category_list');
- if ($c->cobrand->can('hidden_categories')) {
- my %hidden_categories = map { $_ => 1 }
- $c->cobrand->hidden_categories;
-
- @category_options = grep {
- !$hidden_categories{$_}
- } @category_options;
- }
-
# put results onto stash for display
$c->stash->{bodies} = \%bodies;
$c->stash->{all_body_names} = [ map { $_->name } values %bodies ];
@@ -1030,6 +1010,31 @@ sub tokenize_user : Private {
if $c->get_param('oauth_need_email') && $c->session->{oauth}{twitter_id};
}
+sub send_problem_confirm_email : Private {
+ my ( $self, $c ) = @_;
+ my $data = $c->stash->{token_data} || {};
+ my $report = $c->stash->{report};
+ my $token = $c->model("DB::Token")->create( {
+ scope => 'problem',
+ data => {
+ %$data,
+ id => $report->id
+ }
+ } );
+
+ my $template = 'problem-confirm.txt';
+ $template = 'problem-confirm-not-sending.txt' unless $report->bodies_str;
+
+ $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
+ if ($c->cobrand->can('problem_confirm_email_extras')) {
+ $c->cobrand->problem_confirm_email_extras($report);
+ }
+
+ $c->send_email( $template, {
+ to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ],
+ } );
+}
+
=head2 save_user_and_report
Save the user and the report.
@@ -1187,30 +1192,13 @@ sub redirect_or_confirm_creation : Private {
return 1;
}
- my $template = 'problem-confirm.txt';
- $template = 'problem-confirm-not-sending.txt' unless $report->bodies_str;
-
- # otherwise create a confirm token and email it to them.
- my $data = $c->stash->{token_data} || {};
- my $token = $c->model("DB::Token")->create( {
- scope => 'problem',
- data => {
- %$data,
- id => $report->id
- }
- } );
- $c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
- if ($c->cobrand->can('problem_confirm_email_extras')) {
- $c->cobrand->problem_confirm_email_extras($report);
- }
- $c->send_email( $template, {
- to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ],
- } );
+ # otherwise email a confirm token to them.
+ $c->forward( 'send_problem_confirm_email' );
# tell user that they've been sent an email
$c->stash->{template} = 'email_sent.html';
$c->stash->{email_type} = 'problem';
- $c->log->info($report->user->id . ' created ' . $report->id . ', email sent, ' . ($data->{password} ? 'password set' : 'password not set'));
+ $c->log->info($report->user->id . ' created ' . $report->id . ', email sent, ' . ($c->stash->{token_data}->{password} ? 'password set' : 'password not set'));
}
sub create_reporter_alert : Private {
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 16f4aa491..88f480137 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -82,6 +82,13 @@ Display a 404 (not found) or 410 (gone) page. Pass in an optional error message
sub page_error_404_not_found : Private {
my ( $self, $c, $error_msg ) = @_;
+
+ # Try getting static content that might be given under an admin proxy.
+ # First the special generated JavaScript file
+ $c->go('/js/translation_strings', [ $1 ], []) if $c->req->path =~ m{^admin/js/translation_strings\.(.*?)\.js$};
+ # Then a generic static file
+ $c->serve_static_file("web/$1") && return if $c->req->path =~ m{^admin/(.*)};
+
$c->stash->{template} = 'errors/page_error_404_not_found.html';
$c->stash->{error_msg} = $error_msg;
$c->response->status(404);
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 38f344250..da017c57f 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -32,7 +32,7 @@ sub confirm_problem : Path('/P') {
$c->stash->{report} = {
id => 123,
title => 'Title of Report',
- bodies_str => 'True',
+ bodies_str => '1',
url => '/report/123',
service => $c->get_param('service'),
};
@@ -195,7 +195,7 @@ sub confirm_update : Path('/C') {
$c->stash->{problem} = {
id => 123,
title => 'Title of Report',
- bodies_str => 'True',
+ bodies_str => '1',
url => '/report/123',
};
return;
diff --git a/perllib/FixMyStreet/App/View/Web.pm b/perllib/FixMyStreet/App/View/Web.pm
index a92021f0c..d43d3af7e 100644
--- a/perllib/FixMyStreet/App/View/Web.pm
+++ b/perllib/FixMyStreet/App/View/Web.pm
@@ -176,7 +176,8 @@ sub version {
$version_hash{$file} = ( stat( $path ) )[9];
}
$version_hash{$file} ||= '';
- return "$file?$version_hash{$file}";
+ my $admin = $self->template->context->stash->{admin} ? FixMyStreet->config('ADMIN_BASE_URL') : '';
+ return "$admin$file?$version_hash{$file}";
}
sub decode {