mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-01-04 14:50:59 +01:00
Handle nonce in admin logout too
This commit is contained in:
@@ -86,12 +86,20 @@ class AdminController
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
||||
if (method_exists('Grav\Common\Utils', 'getNonce')) {
|
||||
if (method_exists('Grav\Common\Utils', 'getNonce')) {
|
||||
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
||||
if (!isset($this->post['admin-nonce']) || !Utils::verifyNonce($this->post['admin-nonce'], 'admin-form')) {
|
||||
$this->admin->setMessage('Unauthorized', 'error');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ($this->task == 'logout') {
|
||||
$nonce = $this->grav['uri']->param('logout-nonce');
|
||||
$nonce = str_replace('SLASH', '/', $nonce);
|
||||
if (!isset($nonce) || !Utils::verifyNonce($nonce, 'logout-form')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user