add csrf token header to jquery requests
This commit is contained in:
@@ -263,7 +263,7 @@ if ($page == '' || $page == 'overview') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($action == 'jqGetPlanValues') {
|
} elseif ($action == 'jqGetPlanValues') {
|
||||||
$planid = isset($_POST['planid']) ? (int)$_POST['planid'] : 0;
|
$planid = (int)Request::get('planid', 0);
|
||||||
try {
|
try {
|
||||||
$json_result = HostingPlans::getLocal($userinfo, [
|
$json_result = HostingPlans::getLocal($userinfo, [
|
||||||
'id' => $planid
|
'id' => $planid
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ if (CurrentUser::hasSession()) {
|
|||||||
$new_token = Froxlor::genSessionId(20);
|
$new_token = Froxlor::genSessionId(20);
|
||||||
UI::twig()->addGlobal('csrf_token', $new_token);
|
UI::twig()->addGlobal('csrf_token', $new_token);
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
$current_token = $_POST['csrf_token'];
|
$current_token = $_POST['csrf_token'] ?? $_SERVER['HTTP_X_CSRF_TOKEN'] ?? null;
|
||||||
if ($current_token != CurrentUser::getField('csrf_token')) {
|
if ($current_token != CurrentUser::getField('csrf_token')) {
|
||||||
Response::dynamicError('CSRF validation failed');
|
Response::dynamicError('CSRF validation failed');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<meta name="robots" content="noindex, nofollow, noarchive"/>
|
<meta name="robots" content="noindex, nofollow, noarchive"/>
|
||||||
<meta name="googlebot" content="nosnippet"/>
|
<meta name="googlebot" content="nosnippet"/>
|
||||||
<link rel="icon" type="image/x-icon" href="{{ basehref|default('') }}templates/Froxlor/assets/img/icon.png">
|
<link rel="icon" type="image/x-icon" href="{{ basehref|default('') }}templates/Froxlor/assets/img/icon.png">
|
||||||
|
<meta name="csrf-token" content="{{ csrf_token }}" />
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
{% if theme_css is empty %}
|
{% if theme_css is empty %}
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ window.Chart = Chart;
|
|||||||
$(function () {
|
$(function () {
|
||||||
window.$theme = 'Froxlor';
|
window.$theme = 'Froxlor';
|
||||||
|
|
||||||
|
$.ajaxSetup({
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
|
||||||
const tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
const tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
||||||
return new bootstrap.Tooltip(tooltipTriggerEl)
|
return new bootstrap.Tooltip(tooltipTriggerEl)
|
||||||
|
|||||||
Reference in New Issue
Block a user