Commit 72edc658 authored by Wolfgang Knopki's avatar Wolfgang Knopki
Browse files

test dynamic header

parent 9dba8167
Pipeline #120 passed with stage
in 3 seconds
......@@ -10,7 +10,6 @@ function prependChild(parent,child){
parent.insertBefore(child, parent.childNodes[0]);
}
console.log(document.getElementById('loginswitch').getAttribute('authenticated'));
function userAuthenticated(){
let params = new URLSearchParams(window.location.search);
if(params.get('isAuthenticatedUser')){
......@@ -21,6 +20,18 @@ function userAuthenticated(){
return false;
}
}
function sendRequest(URL){
let xhr = new XMLHttpRequest();
xhr.open("POST", URL, true);
let token = $("meta[name='_csrf']").attr("content");
//Send the proper header information along with the request
xhr.setRequestHeader('X-CSRF-TOKEN', token);
xhr.send();
}
/* function head()
* creates header and prepends it to the documents body
*/
......@@ -95,7 +106,8 @@ function head(){
headlink.innerHTML="Account";
headlink.href="/account/";
}else if(document.getElementById('loginswitch').getAttribute('authenticated') == '2'){
headlink.href="./logout";
headlink.onclick="sendRequest('./logout');";
headlink.href="#";
headlink.innerHTML="Logout";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment