aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-06-20 12:37:22 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-06-20 12:37:22 +0100
commit767788ba3856c1b2e81f973cd0c36a446b7dfbfe (patch)
treec48fd331295f17ca9b90f32d8112215dd0318afd /perllib/FixMyStreet/App
parent8e96ff0e64a0b5c96912fa25189d7288d5f1d5ca (diff)
Catch alert subscription with missing ID.
Diffstat (limited to 'perllib/FixMyStreet/App')
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm23
1 files changed, 10 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index ddda02abd..45c26a195 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -115,25 +115,20 @@ sub subscribe_email : Private {
$c->stash->{errors} = [];
$c->forward('process_user');
- my $type = $c->get_param('type');
- push @{ $c->stash->{errors} }, _('Please select the type of alert you want')
- if $type && $type eq 'local' && !$c->get_param('feed');
- if (@{ $c->stash->{errors} }) {
- $c->go('updates') if $type && $type eq 'updates';
- $c->go('list') if $type && $type eq 'local';
- $c->go('index');
- }
-
+ my $type = $c->get_param('type') || "";
if ( $type eq 'updates' ) {
$c->forward('set_update_alert_options');
- }
- elsif ( $type eq 'local' ) {
+ } elsif ( $type eq 'local' ) {
$c->forward('set_local_alert_options');
- }
- else {
+ } else {
$c->detach( '/page_error_404_not_found', [ 'Invalid type' ] );
}
+ push @{ $c->stash->{errors} }, _('Please select the type of alert you want')
+ if !$c->stash->{alert_options};
+
+ $c->go($type eq 'updates' ? 'updates' : 'list') if @{ $c->stash->{errors} };
+
$c->forward('create_alert');
if ( $c->stash->{alert}->confirmed ) {
$c->stash->{confirm_type} = 'created';
@@ -211,6 +206,7 @@ sub set_update_alert_options : Private {
my ( $self, $c ) = @_;
my $report_id = $c->get_param('id');
+ return unless $report_id =~ /^[1-9]\d*$/;
my $options = {
user => $c->stash->{alert_user},
@@ -251,6 +247,7 @@ sub set_local_alert_options : Private {
$type = 'local_problems';
push @params, $2, $1; # Note alert parameters are lon,lat
}
+ return unless $type;
my $options = {
user => $c->stash->{alert_user},