Skip to content

Instantly share code, notes, and snippets.

@caulagi
Created Feb 28, 2021
Embed
What would you like to do?
Find a user asynchronously from the database. If that succeeds, return the user. Else return the error
User.findOne({ email: email }, function (err, user) {
if (err) { return done(err) }
if (!user) {
return done(null, false, { message: ‘Unknown user’ })
}
if (!user.authenticate(password)) {
return done(null, false, { message: ‘Invalid password’ })
}
return done(null, user)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment