Browse Source

send proper csrf header

pull/370/head
glaszig 4 years ago
parent
commit
56097d5629
  1. 3
      includes/csrf.php
  2. 1
      index.php
  3. 9
      js/custom.js

3
includes/csrf.php

@ -6,6 +6,3 @@ include_once('session.php');
if (csrfValidateRequest() && !CSRFValidate()) {
handleInvalidCSRFToken();
}
ensureCSRFSessionToken();
header('X-CSRF-Token', $_SESSION['csrf_token']);

1
index.php

@ -19,6 +19,7 @@
*/
require('includes/csrf.php');
ensureCSRFSessionToken();
include_once('includes/config.php');
include_once(RASPI_CONFIG.'/raspap.php');

9
js/custom.js

@ -167,14 +167,6 @@ function setCSRFTokenHeader(event, xhr, settings) {
}
}
function updateCSRFTokens(event, xhr, settings) {
var newToken = xhr.getResponseHeader("X-CSRF-Token");
if (newToken) {
$('meta[name=csrf_token]').attr('content', newToken);
$('[name=csrf_token]:input').attr('value', newToken);
}
}
function contentLoaded() {
pageCurrent = window.location.href.split("?")[1].split("=")[1];
pageCurrent = pageCurrent.replace("#","");
@ -190,5 +182,4 @@ function contentLoaded() {
$(document)
.ajaxSend(setCSRFTokenHeader)
.ajaxComplete(updateCSRFTokens)
.ready(contentLoaded);
Loading…
Cancel
Save