Skip to content
Snippets Groups Projects
Commit 6c5d1e65 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add csrf token to header via meta tag - used for ajax calls

parent a8d3eece
No related branches found
No related tags found
No related merge requests found
......@@ -81,8 +81,15 @@ if(!$thisstaff->isAdmin()) {
//Keep the session activity alive
$thisstaff->refreshSession();
/******* CSRF Protectin *************/
// Enforce CSRF protection for POSTS
if ($_POST) csrf_ensure_cookie();
if ($_POST && !$ost->checkCSRFToken()) {
Http::response(400, 'Valid CSRF Token Required');
exit;
}
//Add token to the header - used on ajax calls [DO NOT CHANGE THE NAME]
$ost->addExtraHeader('<meta name="csrf_token" content="'.$ost->getCSRFToken().'" />');
/******* SET STAFF DEFAULTS **********/
//Set staff's timezone offset.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment