From c4ac2316c67d64383c401f98165d015c296f36c9 Mon Sep 17 00:00:00 2001
From: Wolfgang Knopki <wolfgang.knopki@hft-stuttgart.de>
Date: Tue, 10 Dec 2019 09:46:38 +0100
Subject: [PATCH] set login button according to SAML status

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

diff --git a/js/headfoot.js b/js/headfoot.js
index a6a2c7f..4e5eaf5 100755
--- a/js/headfoot.js
+++ b/js/headfoot.js
@@ -14,7 +14,7 @@ function userAuthenticated(){
     let params = new URLSearchParams(window.location.search);
     if(params.get('isAuthenticatedUser')){
         return true;
-    }else if(document.getElementById('loginswitch')){
+    }else if(document.getElementById('loginswitch')){   //relikt login via OAuth
         if(document.getElementById('loginswitch').getAttribute('authenticated') == '1'){
             return true;
         }
@@ -111,7 +111,7 @@ function head(){
             for(let k = 0; k< menu[j].combos.length; k++){
                 let combolink = document.createElement('a');
                 combolink.classList.add("dropdown-item");
-                if(userAuthenticated()){
+                if(userAuthenticated() || user){ //either logged in the old way or logged in using SAML
                     if(menu[j].combos[k].link.includes('?')){
                         combolink.href = menu[j].combos[k].link + "&isAuthenticatedUser=true";
                     }else{    
@@ -129,6 +129,10 @@ function head(){
                 headlink.innerHTML="Account";
                 headlink.href="/account/";
             }
+            if(user){ //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");
-- 
GitLab