From 52fb74551c5e8a2fe349eeaaca333d82297e61ad Mon Sep 17 00:00:00 2001
From: Wolfgang Knopki <wolfgang.knopki@hft-stuttgart.de>
Date: Tue, 22 Oct 2019 15:21:04 +0200
Subject: [PATCH] test dynamic header

---
 js/headfoot.js | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/js/headfoot.js b/js/headfoot.js
index 2b39c6e..6c6b883 100755
--- a/js/headfoot.js
+++ b/js/headfoot.js
@@ -22,10 +22,23 @@ function userAuthenticated(){
 }
 
 
+function readCookie(name) {
+    var nameEQ = encodeURIComponent(name) + "=";
+    var ca = document.cookie.split(';');
+    for (var i = 0; i < ca.length; i++) {
+        var c = ca[i];
+        while (c.charAt(0) === ' ')
+            c = c.substring(1, c.length);
+        if (c.indexOf(nameEQ) === 0)
+            return decodeURIComponent(c.substring(nameEQ.length, c.length));
+    }
+    return null;
+}
+
 function sendRequest(URL){
     let xhr = new XMLHttpRequest();
     xhr.open("POST", URL, true);
-    let token = $("meta[name='_csrf']").attr("content");
+    let token = readCookie("XSRF-TOKEN");
     //Send the proper header information along with the request
     xhr.setRequestHeader('X-CSRF-TOKEN', token);
     xhr.send();
-- 
GitLab