Skip to content

Commit

Permalink
If user not logged in redirect to base path (#445)
Browse files Browse the repository at this point in the history
Solved problem when  user not logged in can go to admin/something and view admin dashboard with Error 404.
  • Loading branch information
osrecio authored and flaviocopes committed Apr 21, 2016
1 parent 2cc07fe commit b180e13
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,17 @@ public function onPagesInitialized()
};

if (empty($this->grav['page'])) {
$event = $this->grav->fireEvent('onPageNotFound');
if($this->session->user->count()){
$event = $this->grav->fireEvent('onPageNotFound');

if (isset($event->page)) {
unset($this->grav['page']);
$this->grav['page'] = $event->page;
} else {
throw new \RuntimeException('Page Not Found', 404);
if (isset($event->page)) {
unset($this->grav['page']);
$this->grav['page'] = $event->page;
} else {
throw new \RuntimeException('Page Not Found', 404);
}
}else{
$this->grav->redirect($this->base);
}
}

Expand Down

0 comments on commit b180e13

Please sign in to comment.