1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

add csrf token header to all resource-modifying xhr

This commit is contained in:
glaszig 2019-07-30 17:26:30 +02:00
parent 20bb9fe42f
commit ce3ec131a6

View File

@ -162,6 +162,15 @@ function setupBtns() {
}); });
} }
$.ajaxSetup({
beforeSend: function(xhr, settings) {
var csrfToken = $('meta[name=csrf_token]').attr('content');
if (/^(POST|PATCH|PUT|DELETE)$/i.test(settings.type)) {
xhr.setRequestHeader("X-CSRF-Token", csrfToken);
}
}
});
$().ready(function(){ $().ready(function(){
csrf = $('#csrf_token').val(); csrf = $('#csrf_token').val();
pageCurrent = window.location.href.split("?")[1].split("=")[1]; pageCurrent = window.location.href.split("?")[1].split("=")[1];