mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-04 20:36:03 +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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,6 +454,7 @@ en:
|
||||
GROUPS_HELP: "List of groups the user is part of"
|
||||
ADMIN_ACCESS: "Admin Access"
|
||||
SITE_ACCESS: "Site Access"
|
||||
INVALID_SECURITY_TOKEN: "Invalid Security Token"
|
||||
|
||||
fr:
|
||||
PLUGIN_ADMIN:
|
||||
@@ -1781,6 +1782,7 @@ it:
|
||||
GROUPS_HELP: "Lista dei gruppi a cui appartiene l'utente"
|
||||
ADMIN_ACCESS: "Accesso Amministrazione"
|
||||
SITE_ACCESS: "Accesso Sito"
|
||||
INVALID_SECURITY_TOKEN: "Token di sicurezza non valido"
|
||||
|
||||
de:
|
||||
PLUGIN_ADMIN:
|
||||
|
||||
Reference in New Issue
Block a user