I am having the following problem that I am noticing at this stage of my application, when I signOut with one account, and then I decide to log in with another when executing actions, it keeps bringing the credentials of the first one. But if I signOut again and log in again with this last account, it already brings me the correct credentials. What is happening here? I do not understand and take me with a mode of clearPersistance, but I understood that it has no use for what I need.
useEffect(() => {
onAuthStateChanged(auth, async(logFirebase) => {
if (logFirebase) {
sendEmailVerification(logFirebase)
setUsuarioGlobal(logFirebase);
setUserMail(logFirebase.email);
if (!logFirebase.emailVerified) {
let intervalVerified = setInterval(() =>{
setEmailVerificated(logFirebase.emailVerified)
logFirebase.reload().then(ok =>{
if(logFirebase.emailVerified === true){
setEmailVerificated(logFirebase.emailVerified)
clearInterval(intervalVerified)
}
})
}, 5000)
}
} else {
setUsuarioGlobal(null);
}
});
}, []);
const handleSignOut = () => {
signOut(auth);
};
signInWithEmailAndPassword(auth, email, password)
.catch((error) => {
if (error.code === "auth/user-not-found") {
setErrorMsg("Email no encontrado, registrate!");
}
if (error.code === "auth/wrong-password") {
setErrorMsg("Contraseña incorrecta!");
}