【发布时间】:2020-08-22 13:23:10
【问题描述】:
在登录页面的 html 文件中,我使用 Firebase 执行身份验证,并在身份验证成功后,将给定用户重定向到主页。当我在 express 文件中调用 firebase.auth().currentUser(用于渲染和路由页面)时,我得到 undefined 或当前用户的 null。
谁能帮我理解可能是什么问题?
这是我执行身份验证的方式:
firebase
.auth()
.signInWithEmailAndPassword(temail, tpass)
.then(function(firebaseUser) {
window.location.href = "http://localhost:5000/homepage";
})
.catch(function(error) {
window.alert("incorrect pass");
});
这是我的快递文件中的代码:
app.get("/homepage", (req, res) => {
var user = firebase.auth().currentUser;
console.log("USER IS " + user);
res.render("menu", { title: "Welcome" });
});
【问题讨论】:
标签: node.js firebase express firebase-authentication