diff options
author | Dave Arter <davea@mysociety.org> | 2017-02-14 14:36:32 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-02-14 14:36:32 +0000 |
commit | e198a5b8ba63fb1bae68132d2a81fd6cd4ecf69a (patch) | |
tree | 48a1052c83d144433704102d910b41ee917d1d0c /perllib | |
parent | 8d0430990845f3949985c4539d31f55f4441c238 (diff) | |
parent | 009cc2584a3111ab862a0a6335d6e00df1e08bbf (diff) |
Merge branch 'issues/forcouncils/69-redirect-on-login'
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Auth.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm index 825033f21..b41e88209 100644 --- a/perllib/FixMyStreet/App/Controller/Auth.pm +++ b/perllib/FixMyStreet/App/Controller/Auth.pm @@ -412,14 +412,33 @@ 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; - $redirect = 'my' if $redirect =~ /^admin/ && !$c->user->is_superuser; + 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; } $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. |