Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
hu8813 committed Apr 24, 2024
1 parent 95d4b93 commit 80efa90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion srcs/frontend/js/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion srcs/frontend/js/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ function updateNavigation() {



const menuItems = isLoggedIn ?
const menuItems = isLoggedIn || localStorage.getItem('isLoggedIn') === 'true' ?
['Play!', 'Chat', 'Leaderboard', 'Profile', 'Logout'] :
['Home', 'Login'];

Expand Down
2 changes: 1 addition & 1 deletion srcs/frontend/return.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 80efa90

Please sign in to comment.