我有一个小问题,有两个html页面,在过去的工作。
首先,我有一个登录页面(login.html),其中包含以下代码:
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
window.open("main.html",'_self');
} else {
// No user is signed in.
prompt for login ....
......
}
});
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
do serious work ....
......
} else {
// Let us double check:
let theUser = firebase.auth().currentUser;
if (!theUser) {
// No user is signed in.
window.open("login.html",'_self');
}
// We need some patience :)
......
}
});
一旦用户登录,就应该转到main.html;这就是它过去的工作原理。但现在,不知什么原因;当我登录时,即使我已经提供了我的凭据,流也会转到main.html(正如它应该的那样),但会立即返回到login.html。
我已经能够检查块(在main.html中):
firebase.auth().onAuthStateChanged(function(user) {...}
未检测到我已登录。为什么呢?
附笔。