问题
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