I am using passport-local for my strategy and also using bluebird in order to make this a promise. I am not sure if this is a bad thing to do, but it is what I would like to do. My current problem is I do not know how to get the resolve
and or reject
values from my route.
I will post the local-strategy. Everything works and I am getting the correct information. I just need to get this information to the route and be able to use req.user
I am getting the authUser
and also getting any errors
such as a custom wrong password error. But if seeing the other code helps then let me know.
passport.use(
new LocalStrat((username, password) => {
return new Promise((resolve, reject) => {
controllers.user
.getUserByUsername(username)
.then(user => {
user = user;
return controllers.user.comparePassword(password, user);
})
.then(authUser => {
resolve(authUser);
})
.catch(err => {
reject(err);
});
});
})
);
/* User Login */
router.post('/login', passport.authenticate('local'), (req, res) => {
// Need to access promise values here
console.log(req.user);
});