Do not redirect to /admin for login if admin page does not exist

This commit is contained in:
Matias Griese
2018-09-30 12:19:16 +03:00
parent e6ab169091
commit cc09a4fee9
2 changed files with 8 additions and 1 deletions

View File

@@ -434,7 +434,13 @@ class AdminPlugin extends Plugin
throw new \RuntimeException('Page Not Found', 404);
}
} else {
$this->grav->redirect($this->admin_route);
// Not Found and not logged in: Display login page.
$login_file = $this->grav['locator']->findResource('plugins://admin/pages/admin/login.md');
$page = new Page();
$page->init(new \SplFileInfo($login_file));
$page->slug(basename($this->route));
unset($this->grav['page']);
$this->grav['page'] = $page;
}
}