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

@@ -7,6 +7,7 @@
1. [](#improved)
* Use `Url:post()` to get the `$_POST` variable (allows common security checks/filtering for the POST data)
* Make all form fields to extend field.html.twig
* Do not redirect to `/admin` for login if admin page does not exist
# v1.8.9
## 08/23/2018

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;
}
}