diff --git a/js/headfoot.js b/js/headfoot.js index d9755bd41b75db41717aef712bc8fc6ce0afe74c..97a05a4e8769f87c571a3f653349aab3b6048398 100755 --- a/js/headfoot.js +++ b/js/headfoot.js @@ -23,6 +23,26 @@ function userAuthenticated(){ } } +var user = false; + +function profileExists(){ + + $.get( "/api/v1/profile", function(data) { + let email = data.email + + if(email != ''){ + user = true; + } + }) + .done(function() { + console.log("done fetching profile info"); + }) + .fail(function() { + console.log( "error fetching profile info" ); + }) + return user; +} + function readCookie(cname) { var name = cname + "="; @@ -129,12 +149,7 @@ function head(){ headlink.innerHTML="Account"; headlink.href="/account/"; } - if(typeof user !== 'undefined' && user){ - console.log(user) - }else{ - console.log("user not defined") - } - if(typeof user !== 'undefined' && user){ //user has priority + if(profileExists()){ //user has priority headlink.innerHTML="Logout"; headlink.href="/account/logout"; }