Created
February 28, 2021 16:50
-
-
Save caulagi/1f6357bc52e2dee684e60465b23160e6 to your computer and use it in GitHub Desktop.
Find a user asynchronously from the database. If that succeeds, return the user. Else return the error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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