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/Auth.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index dac9d3ec7..b41e88209 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -412,7 +412,10 @@ Used after signing in to take the person back to where they were.
sub redirect_on_signin : Private {
my ( $self, $c, $redirect ) = @_;
- $redirect = 'my' unless $redirect;
+ unless ( $redirect ) {
+ $c->detach('redirect_to_categories') if $c->user->from_body && scalar @{ $c->user->categories };
+ $redirect = 'my';
+ }
$redirect = 'my' if $redirect =~ /^admin/ && !$c->cobrand->admin_allow_user($c->user);
if ( $c->cobrand->moniker eq 'zurich' ) {
$redirect = 'admin' if $c->user->from_body;
@@ -420,6 +423,22 @@ sub redirect_on_signin : Private {
$c->res->redirect( $c->uri_for( "/$redirect" ) );
}
+=head2 redirect_to_categories
+
+Redirects the user to their body's reports page, prefiltered to whatever
+categories this user has been assigned to.
+
+=cut
+
+sub redirect_to_categories : Private {
+ my ( $self, $c ) = @_;
+
+ my $categories = join(',', @{ $c->user->categories });
+ my $body_short = $c->cobrand->short_name( $c->user->from_body );
+
+ $c->res->redirect( $c->uri_for( "/reports/" . $body_short, { filter_category => $categories } ) );
+}
+
=head2 redirect
Used when trying to view a page that requires sign in when you're not.