I've been failing to get passport.authenticate to work at all inside of an async/await or promise pattern. Here is an example I feel should work, but it fails to execute passport.authenticate().
const passport = require("passport");
let user;
try {
user = await __promisifiedPassportAuthentication();
console.log("You'll never have this ", user);
} catch (err) {
throw err;
}
function __promisifiedPassportAuthentication() {
return new Promise((resolve, reject) => {
console.log("I run");
passport.authenticate('local', (err, user, info) => {
console.log("I never run");
if (err) reject(err);
if (user) resolve(user);
}
}
}
Any sage words of wisdom would be greatly appreciated.