diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-26 14:33:50 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-26 14:33:50 +0100 |
commit | 408b256e4f863a43c4f81209106b4ac23aaa666a (patch) | |
tree | 24682056ebcd864676095583a3656eebc186a905 | |
parent | 0030a9d9760c1f8733fb5b64486aaa634d1023bb (diff) |
If the user already exists in the database then don't sent them a
confirmation email when signing up to alerts
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Alert.pm | 10 | ||||
-rw-r--r-- | t/app/controller/alert_new.t | 9 | ||||
-rw-r--r-- | templates/web/default/alert/confirm.html | 2 |
3 files changed, 16 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm index 7ea0d77e3..b836f5a79 100644 --- a/perllib/FixMyStreet/App/Controller/Alert.pm +++ b/perllib/FixMyStreet/App/Controller/Alert.pm @@ -140,7 +140,12 @@ sub subscribe_email : Private { } $c->forward('create_alert'); - $c->forward('send_confirmation_email'); + if ( $c->stash->{alert}->confirmed ) { + $c->stash->{confirm_type} = 'created'; + $c->stash->{template} = 'alert/confirm.html'; + } else { + $c->forward('send_confirmation_email'); + } } sub updates : Path('updates') : Args(0) { @@ -190,14 +195,13 @@ sub create_alert : Private { unless ($alert) { $options->{cobrand} = $c->cobrand->moniker(); $options->{cobrand_data} = $c->cobrand->extra_update_data(); + $options->{confirmed} = 1 if $c->stash->{alert_user}->in_storage; $alert = $c->model('DB::Alert')->new($options); $alert->insert(); } $c->stash->{alert} = $alert; - - $c->log->debug( 'created alert ' . $alert->id ); } =head2 set_update_alert_options diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 7cbf6188a..4b23cb950 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -181,7 +181,7 @@ foreach my $test ( alert_type => $type, parameter => $test->{param1}, parameter2 => $test->{param2}, - confirmed => 0, + confirmed => 1, } ); @@ -209,6 +209,8 @@ foreach my $test ( $mech->log_in_ok( $test->{email} ); + $mech->clear_emails_ok; + my $alert; if ($user) { $alert = FixMyStreet::App->model('DB::Alert')->find( @@ -237,11 +239,14 @@ foreach my $test ( alert_type => $type, parameter => $test->{param1}, parameter2 => $test->{param2}, - confirmed => 0, + confirmed => 1, } ); ok $alert, 'New alert created with existing user'; + + $mech->email_count_is(0); + }; } diff --git a/templates/web/default/alert/confirm.html b/templates/web/default/alert/confirm.html index 3dc4bed97..07694cbb6 100644 --- a/templates/web/default/alert/confirm.html +++ b/templates/web/default/alert/confirm.html @@ -7,6 +7,8 @@ [% loc('You have successfully confirmed your alert.') %] [% ELSIF confirm_type == 'unsubscribe' %] [% loc('You have successfully deleted your alert.') %] +[% ELSIF confirm_type == 'created' %] + [% loc('You have successfully created your alert.') %] [% END %] </p> |