diff --git a/js/headfoot.js b/js/headfoot.js
index 1015f0d5c96bc2fc80ff6a3c67fa15dd877c29b4..b45cd210b0650aeb89d830b2645ceb4aa5a5a53d 100755
--- a/js/headfoot.js
+++ b/js/headfoot.js
@@ -14,8 +14,10 @@ function userAuthenticated(){
     let params = new URLSearchParams(window.location.search);
     if(params.get('isAuthenticatedUser')){
         return true;
-    }else if(document.getElementById('loginswitch').getAttribute('authenticated') == '1'){
-        return true;
+    }else if(document.getElementById('loginswitch')){
+        if(document.getElementById('loginswitch').getAttribute('authenticated') == '1'){
+            return true;
+        }
     }else{
         return false;
     }