Firebase NodeJS Authentication

2020-08-04 09:53发布

问题:

I have built a fairly basic ExpressJS app and am using Firebase for authentication. When the app loads it checks to see if a user is logged in and if not shows the login screen. The user then enters an email and password and this does a POST to my express ass and logs in the user like so:

app.post('/login-user', function(req, res) {
 firebase.auth().signInWithEmailAndPassword(req.body.email1, req.body.password1).then(function(authData){
   res.redirect('/')
 }).catch(function(error) {
   console.log('mainError', error)
   console.log('error', error.code);
   console.log('message', error.message);
 });
});

This works absolutely fine and the user is logged in and i can access their AuthData.

The issue is this logs the whole app into firebase. If I access the app on another computer it automatically logs in with this user. So basically, only one user can be logged in at one time.

What could I be doing wrong?