Skip to content

Commit

Permalink
Fix: Bug in PR code, to redirect user to home-page after login
Browse files Browse the repository at this point in the history
  • Loading branch information
Etan31 committed Nov 25, 2024
1 parent 070761f commit 7c7ec20
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions js/login-sign-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,26 @@ function checkLoginValidation(e) {
let massege = document.querySelector('#error-massage');
let password = document.querySelector('#pwd').value;
let userName = document.querySelector('#email').value;
console.log(userName); // Is this a debugging statement?
let user = JSON.parse(localStorage.getItem(userName));
if (user == null || user.password != password) {
massege.classList.remove('hide');
return;
massege.classList.remove('hide');
return;
}
const currentUser = {
firstName: user['firstName'],
userName: userName,
highScore: user.highScore,
secondScore: user.secondScore,
firstName: user['firstName'],
userName: userName,
highScore: user.highScore,
secondScore: user.secondScore,
};
sessionStorage.setItem('currentUser', JSON.stringify(currentUser));
massege.classList.add('hide');
modalLogin.hide()
updateHeloUser();
modalLogin.hide();

// Redirect to home page
window.location.href = "../html/icy-tower-home.html";
}


function checkEqualtoPwd() {
let pw = document.querySelector('#pasword-first').value;
if (pw != document.querySelector('#verify-pwd').value) {
Expand Down Expand Up @@ -261,13 +263,16 @@ checkLoginStatus();

// Assuming this function is called when the user logs in
function loginUser(username) {
// Simulate logging in
sessionStorage.setItem('currentUser', username);

// Update the state of the link immediately after login
checkLoginStatus();

// Optionally, hide the login message
loginMessage.style.display = 'none';
// Simulate logging in
sessionStorage.setItem('currentUser', username);

// Update the state of the link immediately after login
checkLoginStatus();

// Optionally, hide the login message
loginMessage.style.display = 'none';

// Redirect to the home page (or any other page)
window.location.href = '../html/icy-tower-home.html'; // Replace 'home.html' with your home page URL
}

0 comments on commit 7c7ec20

Please sign in to comment.