Add CSRF token validation for forms
parent
a446cfd9c1
commit
3e8d0d3778
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue