Closed nullRefErr closed 5 years ago
I found the solution, I did not know that we can use authenticate method as a middleware and then can call another fucntion. So I made these changes and it worked. From:
app.post('/login', passport.authenticate('local-login', {
successRedirect: '/',
failureRedirect: '/err',
}));
To:
app.post('/login', passport.authenticate('local-login'), function(req, res) {
console.log(req.isAuthenticated());
});
Issue can now be closed.
Hello I switched to Passportjs to authenticate and I created simple Express server. I defined routes and local-strategy for passport but I'm always getting false as a output from
req.isAuthenticated()
Edit: Changed the user object to users.
I'm using MacOs 10.14 Mojave and Node version is 8.11.4
Here is the code;