mirror of
https://github.com/getgrav/grav.git
synced 2026-07-06 01:19:30 +02:00
fix for getting admin route when Uri::init() is called after Session::init()
This commit is contained in:
@@ -31,15 +31,18 @@ class Session extends BaseSession
|
||||
$config = $this->grav['config'];
|
||||
|
||||
$is_admin = false;
|
||||
$base_url = $uri->rootUrl(false);
|
||||
|
||||
$session_timeout = $config->get('system.session.timeout', 1800);
|
||||
$session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
|
||||
$session_path = $config->get('system.session.path', '/' . ltrim($base_url, '/'));
|
||||
|
||||
// Activate admin if we're inside the admin path.
|
||||
if ($config->get('plugins.admin.enabled')) {
|
||||
$route = $config->get('plugins.admin.route');
|
||||
// Uri::route() is not processed yet, let's quickly get what we need
|
||||
$current_route = str_replace($base_url, '', parse_url($uri->url(true), PHP_URL_PATH));
|
||||
$base = '/' . trim($route, '/');
|
||||
if (substr($uri->route(), 0, strlen($base)) == $base) {
|
||||
if (substr($current_route, 0, strlen($base)) == $base) {
|
||||
$session_timeout = $config->get('plugins.admin.session.timeout', 1800);
|
||||
$is_admin = true;
|
||||
}
|
||||
@@ -50,7 +53,7 @@ class Session extends BaseSession
|
||||
parent::__construct($session_timeout, $session_path);
|
||||
|
||||
$domain = $uri->host();
|
||||
if ($domain == 'localhost') {
|
||||
if ($domain === 'localhost') {
|
||||
$domain = '';
|
||||
}
|
||||
$secure = $config->get('system.session.secure', false);
|
||||
|
||||
Reference in New Issue
Block a user