Fixed admin controller running before setting $grav['page']

This commit is contained in:
Matias Griese
2021-03-30 18:51:07 +03:00
parent f36b244198
commit 9a86b83dee
2 changed files with 22 additions and 15 deletions

View File

@@ -17,6 +17,7 @@
* Fixed admin user creation and password reset allowing unsafe passwords
* Fixed missing validation when registering the first admin user
* Fixed reset password email not to have session specific token in it
* Fixed admin controller running before setting `$grav['page']`
# v1.10.7
## 03/17/2021

View File

@@ -449,22 +449,9 @@ class AdminPlugin extends Plugin
$this->grav['page'] = $page;
$this->admin->form = $controller->getActiveForm();
$legacyController = false;
} else {
// Handle tasks.
$this->admin->task = $task = $this->grav['task'] ?? $this->grav['action'];
if ($task) {
Admin::DEBUG && Admin::addDebugMessage("Admin task: {$task}");
// Make local copy of POST.
$post = $this->grav['uri']->post();
$this->initializeController($task, $post);
} elseif ($this->template === 'logs' && $this->route) {
// Display RAW error message.
$response = new Response(200, [], $this->admin->logEntry());
$this->grav->close($response);
}
$legacyController = true;
}
// Replace page service with admin.
@@ -558,6 +545,25 @@ class AdminPlugin extends Plugin
}
}
if ($legacyController) {
// Handle tasks.
$this->admin->task = $task = $this->grav['task'] ?? $this->grav['action'];
if ($task) {
Admin::DEBUG && Admin::addDebugMessage("Admin task: {$task}");
// Make local copy of POST.
$post = $this->grav['uri']->post();
$this->initializeController($task, $post);
} elseif ($this->template === 'logs' && $this->route) {
// Display RAW error message.
$response = new Response(200, [], $this->admin->logEntry());
$this->grav->close($response);
}
}
// Explicitly set a timestamp on assets
$this->grav['assets']->setTimestamp(substr(md5(GRAV_VERSION . $this->grav['config']->checksum()), 0, 10));
}