Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The current environment does not support the specified persistence type firebase

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");
        }
    });
});});
like image 770
ihnamdar Avatar asked Jan 04 '23 13:01

ihnamdar


1 Answers

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.

like image 60
bojeil Avatar answered Jan 14 '23 11:01

bojeil