passportjs mac req.user not saved 1

passportjs mac req.user not saved

app.post('/login', passport.authenticate('local-login', { failureRedirect: '/login'}),
  function(req, res) {
     console.log(req.user);
     req.session.user = req.user;
     res.redirect('/users');
  }
);

Here is what the above code is Doing:
1. We are using the passport.authenticate() method to authenticate the user.
2. We are using the local-login strategy that we defined earlier.
3. If the authentication fails, the user will be redirected to the login page.
4. If the authentication succeeds, the user will be redirected to the users page.
5. We are also storing the user in the session.

Similar Posts