diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-10-11 13:33:16 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-10-14 14:36:51 +0100 |
commit | faeb8244d9281c064c832366257ac46d5143a9f1 (patch) | |
tree | e8df17653b2ab58247d49168d0a310fdef5c264f | |
parent | ca2df0362def3476e9bf50a09513fc0a1fe2786a (diff) |
Default dashboard users to cobrand they are on.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Dashboard.pm | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm index 495e47c2a..60c9b0823 100644 --- a/perllib/FixMyStreet/App/Controller/Dashboard.pm +++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm @@ -70,15 +70,20 @@ sub check_page_allowed : Private { $c->detach( '/auth/redirect' ) unless $c->user_exists; - $c->detach( '/page_error_404_not_found' ) - unless $c->user->from_body || $c->user->is_superuser; + my $cobrand_body = $c->cobrand->can('council_area_id') ? $c->cobrand->body : undef; - my $body = $c->user->from_body; - if (!$body && $c->get_param('body')) { - # Must be a superuser, so allow query parameter if given - $body = $c->model('DB::Body')->find({ id => $c->get_param('body') }); + my $body; + if ($c->user->is_superuser) { + if ($c->get_param('body')) { + $body = $c->model('DB::Body')->find({ id => $c->get_param('body') }); + } else { + $body = $cobrand_body; + } + } elsif ($c->user->from_body && (!$cobrand_body || $cobrand_body->id == $c->user->from_body->id)) { + $body = $c->user->from_body; + } else { + $c->detach( '/page_error_404_not_found' ) } - return $body; } |