aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm20
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth.pm13
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm11
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm4
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm3
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm36
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm19
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm48
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Rss.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Tilma.pm46
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm18
13 files changed, 134 insertions, 92 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index f38181be6..63d892fc4 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -62,6 +62,7 @@ sub index : Path : Args(0) {
$c->stash->{problems} = \%prob_counts;
$c->stash->{total_problems_live} += $prob_counts{$_}
for ( FixMyStreet::DB::Result::Problem->visible_states() );
+ $c->stash->{total_problems_users} = $c->cobrand->problems->unique_users;
my $comments = $c->model('DB::Comment')->summary_count( $site_restriction );
@@ -108,6 +109,8 @@ sub index : Path : Args(0) {
: _('n/a');
$c->stash->{questionnaires} = \%questionnaire_counts;
+ $c->stash->{categories} = $c->cobrand->problems->categories_summary();
+
return 1;
}
@@ -120,6 +123,7 @@ sub timeline : Path( 'timeline' ) : Args(0) {
my %time;
$c->model('DB')->schema->storage->sql_maker->quote_char( '"' );
+ $c->model('DB')->schema->storage->sql_maker->name_sep( '.' );
my $probs = $c->cobrand->problems->timeline;
@@ -172,15 +176,22 @@ sub questionnaire : Path('questionnaire') : Args(0) {
my %questionnaire_counts = map { $_->get_column( 'reported' ) => $_->get_column( 'questionnaire_count' ) } $questionnaires->all;
-
$questionnaire_counts{1} ||= 0;
$questionnaire_counts{0} ||= 0;
-
$questionnaire_counts{total} = $questionnaire_counts{0} + $questionnaire_counts{1};
- $c->stash->{reported_pc} = ( 100 * $questionnaire_counts{1} ) / $questionnaire_counts{total};
- $c->stash->{not_reported_pc} = ( 100 * $questionnaire_counts{0} ) / $questionnaire_counts{total};
$c->stash->{questionnaires} = \%questionnaire_counts;
+ $c->stash->{state_changes_count} = $c->model('DB::Questionnaire')->search(
+ { whenanswered => \'is not null' }
+ )->count;
+ $c->stash->{state_changes} = $c->model('DB::Questionnaire')->search(
+ { whenanswered => \'is not null' },
+ {
+ group_by => [ 'old_state', 'new_state' ],
+ columns => [ 'old_state', 'new_state', { c => { count => 'id' } } ],
+ },
+ );
+
return 1;
}
@@ -419,6 +430,7 @@ sub search_reports : Path('search_reports') {
# makes PostgreSQL unhappy elsewhere so we only want to do
# it for this query and then switch it off afterwards.
$c->model('DB')->schema->storage->sql_maker->quote_char( '"' );
+ $c->model('DB')->schema->storage->sql_maker->name_sep( '.' );
my $problems = $c->cobrand->problems->search(
{
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 4ca559fad..660585454 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -239,6 +239,11 @@ sub ajax : Path('/ajax') {
my $all_pins = $c->req->param('all_pins') ? 1 : undef;
my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
+ # Need to be the class that can handle it
+ if ($c->req->param('bbox')) {
+ FixMyStreet::Map::set_map_class( 'OSM' );
+ }
+
# extract the data from the map
my ( $pins, $on_map, $around_map, $dist ) =
FixMyStreet::Map::map_pins( $c, $interval );
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index ebb3510d0..c67de692a 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -36,7 +36,8 @@ sub general : Path : Args(0) {
return unless $req->method eq 'POST';
# decide which action to take
- $c->detach('email_sign_in') if $req->param('email_sign_in');
+ $c->detach('email_sign_in') if $req->param('email_sign_in')
+ || $c->req->param('name') || $c->req->param('password_register');
$c->forward( 'sign_in' )
&& $c->detach( 'redirect_on_signin', [ $req->param('r') ] );
@@ -107,6 +108,11 @@ sub email_sign_in : Private {
return;
}
+ my $user_params = {};
+ $user_params->{password} = $c->req->param('password_register')
+ if $c->req->param('password_register');
+ my $user = $c->model('DB::User')->new( $user_params );
+
my $token_obj = $c->model('DB::Token') #
->create(
{
@@ -115,7 +121,7 @@ sub email_sign_in : Private {
email => $good_email,
r => $c->req->param('r'),
name => $c->req->param('name'),
- password => $c->req->param('password_register'),
+ password => $user->password,
}
}
);
@@ -157,9 +163,8 @@ sub token : Path('/M') : Args(1) {
# find or create the user related to the token.
my $user = $c->model('DB::User')->find_or_create( { email => $data->{email} } );
$user->name( $data->{name} ) if $data->{name};
- $user->password( $data->{password} ) if $data->{password};
+ $user->password( $data->{password}, 1 ) if $data->{password};
$user->update;
-
$c->authenticate( { email => $user->email }, 'no_password' );
# send the user to their page
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index d9baeaaf8..f3607341a 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -39,6 +39,7 @@ sub problems : Local {
# gather the parameters
my $start_date = $c->req->param('start_date') || '';
my $end_date = $c->req->param('end_date') || '';
+ my $category = $c->req->param('category') || '';
my $yyyy_mm_dd = qr{^\d{4}-\d\d-\d\d$};
if ( $start_date !~ $yyyy_mm_dd
@@ -73,25 +74,29 @@ sub problems : Local {
my ( @state, $date_col );
if ( $type eq 'new_problems' ) {
@state = FixMyStreet::DB::Result::Problem->open_states();
- $date_col = 'created';
+ $date_col = 'confirmed';
} elsif ( $type eq 'fixed_problems' ) {
@state = FixMyStreet::DB::Result::Problem->fixed_states();
$date_col = 'lastupdate';
}
my $one_day = DateTime::Duration->new( days => 1 );
- my @problems = $c->cobrand->problems->search( {
+ my $query = {
$date_col => {
'>=' => $start_dt,
'<=' => $end_dt + $one_day,
},
state => [ @state ],
- }, {
+ };
+ $query->{category} = $category if $category;
+ my @problems = $c->cobrand->problems->search( $query, {
order_by => { -asc => 'confirmed' },
columns => [
'id', 'title', 'council', 'category',
'detail', 'name', 'anonymous', 'confirmed',
'whensent', 'service',
+ 'latitude', 'longitude', 'used_map',
+ 'state', 'lastupdate',
]
} );
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index b1359ae03..19b3ffee0 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -25,9 +25,6 @@ sub my : Path : Args(0) {
$c->detach( '/auth/redirect' ) unless $c->user;
- # Even though front end doesn't yet have it, have it on this page, it's better!
- FixMyStreet::Map::set_map_class( 'FMS' );
-
my $p_page = $c->req->params->{p} || 1;
my $u_page = $c->req->params->{u} || 1;
@@ -56,6 +53,7 @@ sub my : Path : Args(0) {
$c->stash->{updates} = \@updates;
$c->stash->{updates_pager} = $rs->pager;
+ $c->stash->{page} = 'my';
FixMyStreet::Map::display_map(
$c,
latitude => $pins->[0]{latitude},
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index 8de935dd7..d9bdb7108 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -289,6 +289,7 @@ sub display : Private {
{ order_by => 'confirmed' }
);
+ $c->stash->{page} = 'questionnaire';
FixMyStreet::Map::display_map(
$c,
latitude => $problem->latitude,
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index a15ee993f..6596615c6 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -108,8 +108,6 @@ sub format_problem_for_display : Private {
map { Utils::truncate_coordinate($_) }
( $problem->latitude, $problem->longitude );
- $c->stash->{report_name} = $c->req->param('name');
-
unless ( $c->req->param('submit_update') ) {
$c->stash->{add_alert} = 1;
}
@@ -124,6 +122,7 @@ sub generate_map_tags : Private {
my $problem = $c->stash->{problem};
+ $c->stash->{page} = 'report';
FixMyStreet::Map::display_map(
$c,
latitude => $problem->latitude,
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 3a7d18a1c..346dfb377 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -220,13 +220,15 @@ sub report_import : Path('/import') {
anonymous => 0,
category => '',
areas => '',
+ cobrand => $c->cobrand->moniker,
+ lang => $c->stash->{lang_code},
}
);
# If there was a photo add that too
- if ( my $fileid = $c->stash->{upload_fileid} ) {
- my $file = file( $c->config->{UPLOAD_CACHE}, "$fileid.jpg" );
+ if ( $photo ) {
+ my $file = file( $c->config->{UPLOAD_CACHE}, "$photo.jpg" );
my $blob = $file->slurp;
$file->remove;
$report->photo($blob);
@@ -489,7 +491,7 @@ sub setup_categories_and_councils : Private {
next # TODO - move this to the cobrand
if $c->cobrand->moniker eq 'southampton'
- && $contact->category eq 'Street lighting';
+ && $contact->category =~ /Street lighting|Traffic lights/;
next if $contact->category eq _('Other');
@@ -571,9 +573,9 @@ sub process_user : Private {
unless $report->user;
# The user is trying to sign in. We only care about email from the params.
- if ( $c->req->param('submit_sign_in') ) {
+ if ( $c->req->param('submit_sign_in') || $c->req->param('password_sign_in') ) {
unless ( $c->forward( '/auth/sign_in' ) ) {
- $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
+ $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Passwords and user accounts are a brand <strong>new</strong> service, so you probably do not have one yet &ndash; please fill in the right hand side of this form to get one.');
return 1;
}
my $user = $c->user->obj;
@@ -608,6 +610,7 @@ sub process_report : Private {
map { $_ => scalar $c->req->param($_) } #
(
'title', 'detail', 'pc', #
+ 'detail_size', 'detail_depth',
'may_show_name', #
'category', #
'partial', #
@@ -626,8 +629,14 @@ sub process_report : Private {
# clean up text before setting
$report->title( Utils::cleanup_text( $params{title} ) );
- $report->detail(
- Utils::cleanup_text( $params{detail}, { allow_multiline => 1 } ) );
+
+ my $detail = Utils::cleanup_text( $params{detail}, { allow_multiline => 1 } );
+ for my $w ('depth', 'size') {
+ next unless $params{"detail_$w"};
+ next if $params{"detail_$w"} eq '-- Please select --';
+ $detail .= "\n\n\u$w: " . $params{"detail_$w"};
+ }
+ $report->detail( $detail );
# set these straight from the params
$report->category( _ $params{category} );
@@ -845,9 +854,13 @@ sub save_user_and_report : Private {
$report->confirm;
}
else {
-
- # user exists and we are not logged in as them. Throw away changes to
- # the name and phone. TODO - propagate changes using tokens.
+ # User exists and we are not logged in as them.
+ # Store changes in token for when token is validated.
+ $c->stash->{token_data} = {
+ name => $report->user->name,
+ phone => $report->user->phone,
+ password => $report->user->password,
+ };
$report->user->discard_changes();
}
@@ -895,6 +908,7 @@ sub generate_map : Private {
# Don't do anything if the user skipped the map
unless ( $c->req->param('skipped') ) {
+ $c->stash->{page} = 'new';
FixMyStreet::Map::display_map(
$c,
latitude => $latitude,
@@ -932,9 +946,11 @@ sub redirect_or_confirm_creation : Private {
}
# 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
}
} );
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index 2916e1ee1..add9d1371 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -120,9 +120,9 @@ sub process_user : Private {
unless $update->user;
# The user is trying to sign in. We only care about email from the params.
- if ( $c->req->param('submit_sign_in') ) {
+ if ( $c->req->param('submit_sign_in') || $c->req->param('password_sign_in') ) {
unless ( $c->forward( '/auth/sign_in', [ $email ] ) ) {
- $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
+ $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Passwords and user accounts are a brand <strong>new</strong> service, so you probably do not have one yet &ndash; please fill in the right hand side of this form to get one.');
return 1;
}
my $user = $c->user->obj;
@@ -180,8 +180,7 @@ sub process_update : Private {
if ( $params{state} ) {
$params{state} = 'fixed - council'
- if $params{state} eq 'fixed' && $c->user && $c->user->from_council
- && $c->user->from_council == $update->problem->council;
+ if $params{state} eq 'fixed' && $c->user && $c->user->belongs_to_council( $update->problem->council );
$update->problem_state( $params{state} );
}
@@ -205,7 +204,7 @@ sub check_for_errors : Private {
# they have to be an authority user to update the state
if ( $c->req->param('state') ) {
my $error = 0;
- $error = 1 unless $c->user && $c->user->from_council && $c->user->from_council == $c->stash->{update}->problem->council;
+ $error = 1 unless $c->user && $c->user->belongs_to_council( $c->stash->{update}->problem->council );
my $state = $c->req->param('state');
$error = 1 unless ( grep { $state eq $_ } ( qw/confirmed closed fixed investigating planned/, 'in progress', 'fixed', 'fixed - user', 'fixed - council' ) );
@@ -262,6 +261,14 @@ sub save_update : Private {
# Logged in and same user, so can confirm update straight away
$update->user->update;
$update->confirm;
+ } else {
+ # User exists and we are not logged in as them.
+ # Store changes in token for when token is validated.
+ $c->stash->{token_data} = {
+ name => $update->user->name,
+ password => $update->user->password,
+ };
+ $update->user->discard_changes();
}
# If there was a photo add that too
@@ -303,10 +310,12 @@ sub redirect_or_confirm_creation : Private {
}
# otherwise create a confirm token and email it to them.
+ my $data = $c->stash->{token_data} || {};
my $token = $c->model("DB::Token")->create(
{
scope => 'comment',
data => {
+ %$data,
id => $update->id,
add_alert => ( $c->req->param('add_alert') ? 1 : 0 ),
}
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 9cec0fdfe..821b650ed 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -34,10 +34,18 @@ sub index : Path : Args(0) {
$c->response->header('Cache-Control' => 'max-age=3600');
# Fetch all areas of the types we're interested in
- my @area_types = $c->cobrand->area_types;
- my $areas_info = mySociety::MaPit::call('areas', \@area_types,
- min_generation => $c->cobrand->area_min_generation
- );
+ my $areas_info;
+ eval {
+ my @area_types = $c->cobrand->area_types;
+ $areas_info = mySociety::MaPit::call('areas', \@area_types,
+ min_generation => $c->cobrand->area_min_generation
+ );
+ };
+ if ($@) {
+ $c->stash->{message} = _("Unable to look up areas in MaPit. Please try again later.") . ' ' .
+ sprintf(_('The error was: %s'), $@);
+ $c->stash->{template} = 'errors/generic.html';
+ }
# For each area, add its link and perhaps alter its name if we need to for
# places with the same name.
@@ -61,7 +69,8 @@ sub index : Path : Args(0) {
$c->stash->{open} = $j->{open};
};
if ($@) {
- $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.");
+ $c->stash->{message} = _("There was a problem showing the All Reports page. Please try again later.") . ' ' .
+ sprintf(_('The error was: %s'), $@);
$c->stash->{template} = 'errors/generic.html';
}
}
@@ -90,6 +99,7 @@ sub ward : Path : Args(2) {
$c->forward( 'ward_check', [ $ward ] )
if $ward;
$c->forward( 'load_parent' );
+ $c->forward( 'check_canonical_url', [ $council ] );
$c->forward( 'load_and_group_problems' );
$c->forward( 'sort_problems' );
@@ -102,8 +112,7 @@ sub ward : Path : Args(2) {
my $pins = $c->stash->{pins};
- # Even though front end doesn't yet have it, have it on this page, it's better!
- FixMyStreet::Map::set_map_class( 'FMS' );
+ $c->stash->{page} = 'reports'; # So the map knows to make clickable pins
FixMyStreet::Map::display_map(
$c,
latitude => @$pins ? $pins->[0]{latitude} : 0,
@@ -227,7 +236,7 @@ sub council_check : Private {
return;
} else {
foreach (keys %$areas) {
- if ($areas->{$_}->{name} eq $q_council || $areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/) {
+ if (lc($areas->{$_}->{name}) eq lc($q_council) || $areas->{$_}->{name} =~ /^\Q$q_council\E (Borough|City|District|County) Council$/i) {
$c->stash->{council} = $areas->{$_};
return;
}
@@ -252,6 +261,7 @@ sub ward_check : Private {
$ward =~ s/\+/ /g;
$ward =~ s/\.html//;
+ $ward =~ s{_}{/}g;
my $council = $c->stash->{council};
@@ -281,6 +291,22 @@ sub load_parent : Private {
}
}
+=head2 check_canonical_url
+
+Given an already found (case-insensitively) council, check what URL
+we are at and redirect accordingly if different.
+
+=cut
+
+sub check_canonical_url : Private {
+ my ( $self, $c, $q_council ) = @_;
+
+ my $council_short = $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} );
+ my $url_short = URI::Escape::uri_escape_utf8($q_council);
+ $url_short =~ s/%2B/+/g;
+ $c->detach( 'redirect_area' ) unless $council_short eq $url_short;
+}
+
sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
@@ -290,9 +316,9 @@ sub load_and_group_problems : Private {
state => [ FixMyStreet::DB::Result::Problem->visible_states() ]
};
if ($c->stash->{ward}) {
- $where->{areas} = { 'like', '%' . $c->stash->{ward}->{id} . '%' }; # FIXME Check this is secure
+ $where->{areas} = { 'like', '%,' . $c->stash->{ward}->{id} . ',%' };
} elsif ($c->stash->{council}) {
- $where->{areas} = { 'like', '%' . $c->stash->{council}->{id} . '%' };
+ $where->{areas} = { 'like', '%,' . $c->stash->{council}->{id} . ',%' };
}
my $problems = $c->cobrand->problems->search(
$where,
@@ -369,7 +395,7 @@ sub redirect_area : Private {
my $url = '';
$url .= "/rss" if $c->stash->{rss};
$url .= '/reports';
- $url .= '/' . $c->cobrand->short_name( $c->stash->{council} );
+ $url .= '/' . $c->cobrand->short_name( $c->stash->{council}, $c->stash->{areas_info} );
$url .= '/' . $c->cobrand->short_name( $c->stash->{ward} )
if $c->stash->{ward};
$c->res->redirect( $c->uri_for($url) );
diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm
index db4955f06..78793d9c1 100755
--- a/perllib/FixMyStreet/App/Controller/Rss.pm
+++ b/perllib/FixMyStreet/App/Controller/Rss.pm
@@ -217,7 +217,7 @@ sub add_row : Private {
my ( $self, $c, $row ) = @_;
my $alert_type = $c->stash->{alert_type};
- $row->{name} ||= 'anonymous';
+ $row->{name} = 'anonymous' if $row->{anonymous} || !$row->{name};
my $pubDate;
if ($row->{confirmed}) {
diff --git a/perllib/FixMyStreet/App/Controller/Tilma.pm b/perllib/FixMyStreet/App/Controller/Tilma.pm
deleted file mode 100644
index 1be481949..000000000
--- a/perllib/FixMyStreet/App/Controller/Tilma.pm
+++ /dev/null
@@ -1,46 +0,0 @@
-package FixMyStreet::App::Controller::Tilma;
-use Moose;
-use namespace::autoclean;
-
-BEGIN { extends 'Catalyst::Controller'; }
-
-use LWP::UserAgent;
-
-=head1 NAME
-
-FixMyStreet::App::Controller::Tilma - Tilma proxy
-
-=head1 DESCRIPTION
-
-A tilma proxy - only intended to be used during dev. In production the webserver should do this proxying.
-
-=head1 METHODS
-
-=head2 default
-
-Proxy everything through to the tilma servers.
-
-=cut
-
-sub default : Path {
- my ( $self, $c ) = @_;
-
- my $path = $c->req->uri->path_query;
- $path =~ s{/tilma/}{};
-
- my $tilma_uri = URI->new("http://tilma.mysociety.org/$path");
-
- my $tilma_res = LWP::UserAgent->new->get($tilma_uri);
-
- if ( $tilma_res->is_success ) {
- $c->res->content_type( $tilma_res->content_type );
- $c->res->body( $tilma_res->content );
- }
- else {
- die sprintf "Error getting %s: %s", $tilma_uri, $tilma_res->message;
- }
-}
-
-__PACKAGE__->meta->make_immutable;
-
-1;
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 1fef0f07e..9abef591d 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -32,7 +32,8 @@ sub confirm_problem : Path('/P') {
$c->forward( 'load_auth_token', [ $token_code, 'problem' ] );
# Load the problem
- my $problem_id = $auth_token->data->{id};
+ my $data = $auth_token->data;
+ my $problem_id = $data->{id};
my $problem = $c->cobrand->problems->find( { id => $problem_id } )
|| $c->detach('token_error');
$c->stash->{problem} = $problem;
@@ -59,6 +60,11 @@ sub confirm_problem : Path('/P') {
$c->forward( '/report/new/create_reporter_alert' );
# log the problem creation user in to the site
+ if ( $data->{name} || $data->{password} ) {
+ $problem->user->name( $data->{name} ) if $data->{name};
+ $problem->user->password( $data->{password}, 1 ) if $data->{password};
+ $problem->user->update;
+ }
$c->authenticate( { email => $problem->user->email }, 'no_password' );
$c->set_session_cookie_expire(0);
@@ -133,8 +139,9 @@ sub confirm_update : Path('/C') {
$c->forward( 'load_auth_token', [ $token_code, 'comment' ] );
# Load the problem
- my $comment_id = $auth_token->data->{id};
- $c->stash->{add_alert} = $auth_token->data->{add_alert};
+ my $data = $auth_token->data;
+ my $comment_id = $data->{id};
+ $c->stash->{add_alert} = $data->{add_alert};
my $comment = $c->model('DB::Comment')->find( { id => $comment_id } )
|| $c->detach('token_error');
@@ -146,6 +153,11 @@ sub confirm_update : Path('/C') {
return;
}
+ if ( $data->{name} || $data->{password} ) {
+ $comment->user->name( $data->{name} ) if $data->{name};
+ $comment->user->password( $data->{password}, 1 ) if $data->{password};
+ $comment->user->update;
+ }
$c->authenticate( { email => $comment->user->email }, 'no_password' );
$c->set_session_cookie_expire(0);