The current environment does not support the specified persistence type firebase

早过忘川 提交于 2020-05-13 07:56:06

问题


I get this error. "The current environment does not support the specified persistence type." I was testing my app and saw that when a user is logged in it's logged in everywhere. So I'm trying to implement sessions on node.js express using firebase hoping this will solve it. My code is this:

router.post("/login", function (req, res) {
email = req.body.email;
password = req.body.password;

firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION);
firebase.auth().signInWithEmailAndPassword(email, password).then(function () {
    var user = firebase.auth().currentUser;
    firebase.auth().onAuthStateChanged(function (user) {
        if (user) {

            res.redirect("/home");
        }
    });
});});

回答1:


Only none persistence is supported in a node.js environment (it is the default setting). The reason for this is because when Firebase Auth client library is used in a server environment, you could have multiple users logging in and you don't have the notion of a currentUser that is persisted on the backend server (this would cause one user to clobber the other). Session persistence can be modified on the client only.



来源:https://stackoverflow.com/questions/45850962/the-current-environment-does-not-support-the-specified-persistence-type-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!