【发布时间】:2017-09-13 05:39:29
【问题描述】:
githubLogin.addEventListener('click', () => {
var provider = new firebase.auth.GithubAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
var user = result.user;
console.log(user);
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
window.location = "pages/welcome.html";
}});
}).catch(function(error) {
console.log(error);
});
});
所以问题是,当我将用户重定向到 Welcome 时,我看到该页面上没有用户登录。 我知道我必须使用 onAuthStateChanged() 函数,但到目前为止我错了。我可以知道如何做到这一点吗?而且我也有类似的谷歌登录,这会影响功能吗?
【问题讨论】:
标签: javascript firebase firebase-authentication