mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-05 04:46:03 +01:00
Allow to set the nonce for a POST action in the query url too
This commit is contained in:
@@ -90,7 +90,12 @@ class AdminController
|
|||||||
{
|
{
|
||||||
if (method_exists('Grav\Common\Utils', 'getNonce')) {
|
if (method_exists('Grav\Common\Utils', 'getNonce')) {
|
||||||
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
|
||||||
if (!isset($this->post['admin-nonce']) || !Utils::verifyNonce($this->post['admin-nonce'], 'admin-form')) {
|
if (isset($this->post['admin-nonce'])) {
|
||||||
|
$nonce = $this->post['admin-nonce'];
|
||||||
|
} else {
|
||||||
|
$nonce = $this->grav['uri']->param('admin-nonce');
|
||||||
|
}
|
||||||
|
if (!$nonce || !Utils::verifyNonce($nonce, 'admin-form')) {
|
||||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN'), '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')];
|
$this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.INVALID_SECURITY_TOKEN')];
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user