1
0
Fork 0

Add CSRF token validation for forms

master
Anonymous Contributor 2023-08-23 18:16:34 +02:00
parent a446cfd9c1
commit 3e8d0d3778
1 changed files with 4 additions and 0 deletions

View File

@ -8,6 +8,10 @@ class FormValidator {
}
public function isValid(array $req) {
if(!isset($req['csrf']) || $req['csrf'] !== $_SESSION['csrf']) {
return false;
}
foreach($fieldValidation as $field => $params) {
if($params['required'] && (!isset($req[$field]) || strlen($req[$field]) == 0)) {
return false;