我需要一些帮助来解决我的问题。
firebase.auth().onAuthStateChanged(user => {
if(user) {
console.log('log in');
window.location.href ='event_list.html'
}});
btnLogout.addEventListener('click', e => {
firebase.auth().signOut().then(function() {
console.log("not log in");
window.location.href = 'index.html';
}, function(error) {
//
});;
});
登录工作正常,但如果我尝试注销 - 用户可能正确注销 - 返回登录/注册网站,但我会立即重定向到“event_list.html”,因为仍然登录用户。
我的登录/注册网站是 -index.html
我想要注销并输入其他数据 - 登录/通行证。
另一个问题:如何从此脚本获取电子邮件变量并在其他 JavaScript 脚本中使用它?
我想要做横幅 - 你好(用户实际登录的邮件),欢迎回来并将其插入到我的所有 HTML 站点中。
我建议你看看这个代码在github上 https://github.com/firebase/FirebaseUI-Web.
关于你的例子,我认为问题在于onAuthStateChanged
方法(用户已注销,因此身份验证状态已更改,因此被触发...)。
尝试使用signInWithEmailAndPassword
解释了什么here https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signInWithEmailAndPassword.
通过其他方式,我会提出单独的问题,首先在SO中进行搜索 https://stackoverflow.com/search?q=get%20user%20email%20firebase,然后,如果没有答案满足我的需求,我会在新的答案中提问!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)