I have a file called login.html. In this file I have this code:
onAuthStateChanged(auth, (user) => {
if (user) {
console.log("there is a user now xD")
window.location.href = "/HomePage/Home.html"
} else {
console.log("No user big boy")
}
})
Basically all that this code does is check if a user is logged into firebase and if they are logged in it takes them to a the home page.
I have another view called createAccount.html. When I finish creating an account it automatically logs in the user which makes the code above run in login.html because the onAuthStateChanged function has changed.
My question is why is the code from login.html running even though I am in createAccount.html? And how do I stop it from running?