mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 19:06:16 +01:00
Return "Invalid Security Token" instead of "Unauthorized". Also, return that string for AJAX calls
This commit is contained in:
@@ -89,7 +89,8 @@ class AdminController
|
||||
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');
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
|
||||
return false;
|
||||
}
|
||||
unset($this->post['admin-nonce']);
|
||||
@@ -97,13 +98,15 @@ class AdminController
|
||||
if ($this->task == 'logout') {
|
||||
$nonce = $this->grav['uri']->param('logout-nonce');
|
||||
if (!isset($nonce) || !Utils::verifyNonce($nonce, 'logout-form')) {
|
||||
$this->admin->setMessage('Unauthorized', 'error');
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$nonce = $this->grav['uri']->param('admin-nonce');
|
||||
if (!isset($nonce) || !Utils::verifyNonce($nonce, 'admin-form')) {
|
||||
$this->admin->setMessage('Unauthorized', 'error');
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), 'error');
|
||||
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user