You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since mongoose 7, findOne no longer accepts a callback. However, the documentation on both the readme of this github and your passport-local strategy page have this example block of code that tries to use a callback. This then fails.
It needs to be re-written to use promises or async await. I changed it to promises here and this works.
passport.use(newLocalStrategy(function(username,password,done){User.findOne({username: username}).then((user)=>{if(!user){returndone(null,false);// No user found with that username}returnuser.verifyPassword(password).then((isMatch)=>{if(!isMatch){returndone(null,false);// Password did not match}});returndone(null,user);// Successful authentication}).catch((err)=>{returndone(err);// Error during the process});})
Environment
Operating System: Mac OS
Node version: 20.16
passport version: 0.7.0
passport-local version: 1.0.0
mongoose version: 8.5.3
The text was updated successfully, but these errors were encountered:
Since mongoose 7, findOne no longer accepts a callback. However, the documentation on both the readme of this github and your passport-local strategy page have this example block of code that tries to use a callback. This then fails.
It needs to be re-written to use promises or async await. I changed it to promises here and this works.
Environment
The text was updated successfully, but these errors were encountered: