我正在使用firebase auth来处理我网站上的用户身份验证,但是当从一个页面移动到另一个页面时会出现连续性问题 . 仅在使用Safari运行时才会出现此问题 . 在谷歌浏览器中,它完美无缺 .
当用户登录“login.html”时,onAuthStateChanged():
firebase.auth().onAuthStateChanged(function(user){
if (user){
//User is signed in
console.log("And now we're on the page");
console.log(user2);
//Lead User to Main ShareHub Page
setTimeout(function (){
window.location.replace("./td/AuthStoreTrans.html");
}, 10000);
} else {
}
});
被调用,页面成功加载主页“AuthStoreTrans.html” . 用户仍然在主页面上登录,并且能够执行他们需要的 Ant 操作 . 但是,当用户单击注销按钮时:
btnLogout.addEventListener('click', function() {
firebase.auth().signOut().then(function() {
// Sign-out successful.
setTimeout(function (){
window.location.replace("../login.html");
}, 5000);
}).catch(function(error) {
// An error happened.
console.log(error);
});
console.log('User signed out');
});
用户应该退出并被发送回登录页面,由于某种原因,仍然发现用户仍然登录,并且再次执行onAuthStateChanged(),将用户发送回仍然记录的主页面out,没有数据加载 . 我不确定我是否遗漏了必要的东西 - 但是如果我关闭浏览器并重新加载登录页面,那么用户就会成功注销,并且不会重定向到主页面 .
任何帮助表示感谢,谢谢!