From de51f59ef9a50bce0ef63a883c590d1feeadca5d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 5 Aug 2021 17:38:36 +0200 Subject: Show error message if CSRF token does not matches Print an error message for various actions in the administration area if the security token is invalid, instead of silently preventing the user's desired action to perform if the token is invalid for some reason. This change applies for the delete actions on all entity types and also for the login action and the database command execution form; the forms for creating/modifying entities had already shown a CSRF error before. --- admin/user/delete.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'admin/user/delete.php') diff --git a/admin/user/delete.php b/admin/user/delete.php index 5a38b53..31389a2 100644 --- a/admin/user/delete.php +++ b/admin/user/delete.php @@ -25,13 +25,17 @@ if(!$User = $UserRepository->find(HTTP::GET('id'))) { #=============================================================================== # Check for delete request #=============================================================================== -if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'delete')) { - try { - if($UserRepository->delete($User)) { - HTTP::redirect(Application::getAdminURL('user/')); +if(HTTP::issetPOST('delete')) { + if(HTTP::issetPOST(['token' => Application::getSecurityToken()])) { + try { + if($UserRepository->delete($User)) { + HTTP::redirect(Application::getAdminURL('user/')); + } + } catch(PDOException $Exception) { + $messages[] = $Exception->getMessage(); } - } catch(PDOException $Exception) { - $messages[] = $Exception->getMessage(); + } else { + $messages[] = $Language->text('error_security_csrf'); } } -- cgit v1.2.3