aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/send-reports2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm10
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm1
-rw-r--r--t/app/controller/report_new.t10
5 files changed, 25 insertions, 6 deletions
diff --git a/bin/send-reports b/bin/send-reports
index 9ab6f8274..173d78a52 100755
--- a/bin/send-reports
+++ b/bin/send-reports
@@ -425,7 +425,7 @@ sub post_london_report {
# Nearest things
sub london_lookup {
- my $org = shift;
+ my $org = shift || '';
my $str = "Unknown ($org)";
open(FP, "$FindBin::Bin/../data/dft.csv");
while (<FP>) {
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 1e6a3a088..1b023acc3 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -874,6 +874,16 @@ sub save_user_and_report : Private {
# Save or update the user if appropriate
if ( !$report->user->in_storage ) {
+ # User does not exist.
+ # 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->name( undef );
+ $report->user->phone( undef );
+ $report->user->password( '', 1 );
$report->user->insert();
}
elsif ( $c->user && $report->user->id == $c->user->id ) {
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index add9d1371..c67ca4d1f 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -255,6 +255,14 @@ sub save_update : Private {
my $update = $c->stash->{update};
if ( !$update->user->in_storage ) {
+ # User does not exist.
+ # Store changes in token for when token is validated.
+ $c->stash->{token_data} = {
+ name => $update->user->name,
+ password => $update->user->password,
+ };
+ $update->user->name( undef );
+ $update->user->password( '', 1 );
$update->user->insert;
}
elsif ( $c->user && $c->user->id == $update->user->id ) {
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 10f994d9f..b974f94e6 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -69,6 +69,7 @@ sub confirm_problem : Path('/P') {
# log the problem creation user in to the site
if ( ref($data) && ( $data->{name} || $data->{password} ) ) {
$problem->user->name( $data->{name} ) if $data->{name};
+ $problem->user->phone( $data->{phone} ) if $data->{phone};
$problem->user->password( $data->{password}, 1 ) if $data->{password};
$problem->user->update;
}
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index 9158231df..06d49e3c1 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -374,9 +374,11 @@ foreach my $test (
FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
ok $user, "user found";
if ($test->{user}) {
+ is $user->name, 'Old Name', 'name unchanged';
ok $user->check_password('old_password'), 'password unchanged';
} else {
- ok $user->check_password('secret'), 'password set correctly';
+ is $user->name, undef, 'name not yet set';
+ is $user->password, '', 'password not yet set for new user';
}
# find the report
@@ -405,10 +407,8 @@ foreach my $test (
$mech->get_ok( '/report/' . $report->id );
- if ($test->{user}) {
- is $report->name, 'Joe Bloggs', 'name updated correctly';
- ok $report->user->check_password('secret'), 'password updated correctly';
- }
+ is $report->name, 'Joe Bloggs', 'name updated correctly';
+ ok $report->user->check_password('secret'), 'password updated correctly';
# check that the reporter has an alert
my $alert = FixMyStreet::App->model('DB::Alert')->find( {