From 1ec3f07f0ce4e464df556d80c14fe80ddba000b5 Mon Sep 17 00:00:00 2001
From: Wolfgang Knopki <wolfgang.knopki@hft-stuttgart.de>
Date: Tue, 10 Dec 2019 13:58:48 +0100
Subject: [PATCH] user profile fetch / change login button

---
 js/headfoot.js | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/js/headfoot.js b/js/headfoot.js
index 97a05a4..fb20409 100755
--- a/js/headfoot.js
+++ b/js/headfoot.js
@@ -25,13 +25,14 @@ function userAuthenticated(){
 
 var user = false;
 
-function profileExists(){
+function profileExistsSetLogin(){
     
     $.get( "/api/v1/profile", function(data) {
         let email = data.email
-        
         if(email != ''){
             user = true;
+            document.getElementById("navbarDropdown4").innerHTML="Logout";
+            document.getElementById("navbarDropdown4").href="/account/logout";
         }
     })
     .done(function() {
@@ -149,10 +150,6 @@ function head(){
                 headlink.innerHTML="Account";
                 headlink.href="/account/";
             }
-            if(profileExists()){ //user has priority
-                headlink.innerHTML="Logout";
-                headlink.href="/account/logout";
-            }
             headlink.classList.remove("nav-link");
             headlink.classList.add("btn");
             headlink.classList.add("btn-outline-dark");
@@ -160,6 +157,7 @@ function head(){
         headitem.appendChild(headlink);
         navelements.appendChild(headitem);
     }
+    profileExistsSetLogin() //user has priority
     let searchitem = document.createElement('li');
     searchitem.classList.add("nav-item");
     let searchinput = document.createElement('input');
-- 
GitLab