diff --git a/srcs/frontend/js/Profile.js b/srcs/frontend/js/Profile.js index c4e4122..a421175 100644 --- a/srcs/frontend/js/Profile.js +++ b/srcs/frontend/js/Profile.js @@ -336,7 +336,8 @@ async function deleteProfile() { async function fetchAndDisplayProfile() { const errorMessageElement = document.getElementById('errorMessage'); csrfToken = await getCSRFCookie(); - + updateNavigation() ; + translate(currentLanguage); try { const profileData = await fetchProfileData(); const user = profileData.user_info || {}; @@ -345,6 +346,13 @@ async function fetchAndDisplayProfile() { const email = user.email || 'Not available'; const score = user.score || 0; const csrfTokenNew = user.csrfToken || csrfToken; + let isLoggedIn2; + if (localStorage.getItem('isLoggedIn') === 'true') { + if (typeof isLoggedIn === 'undefined') + isLoggedIn2 = true; + else if (isLoggedIn === false) + isLoggedIn2 = true; + } if (csrfTokenNew) setCSRFCookie(csrfTokenNew); diff --git a/srcs/frontend/js/router.js b/srcs/frontend/js/router.js index 63d4444..1966418 100644 --- a/srcs/frontend/js/router.js +++ b/srcs/frontend/js/router.js @@ -484,7 +484,7 @@ function updateNavigation() { - const menuItems = isLoggedIn ? + const menuItems = isLoggedIn || localStorage.getItem('isLoggedIn') === 'true' ? ['Play!', 'Chat', 'Leaderboard', 'Profile', 'Logout'] : ['Home', 'Login']; diff --git a/srcs/frontend/return.html b/srcs/frontend/return.html index 964df9c..ef6a918 100644 --- a/srcs/frontend/return.html +++ b/srcs/frontend/return.html @@ -81,7 +81,7 @@ const userNickname = userData.userNickname || userData.nickname; localStorage.setItem("isLoggedIn", true); localStorage.setItem("userNickname", userNickname ); - + //let isLoggedIn = true; setTimeout(() => { window.location.href = "/#profile"; }, 2000);