Skip to content

Instantly share code, notes, and snippets.

@klinyecviktor
Last active October 23, 2017 18:02
Show Gist options
  • Save klinyecviktor/f4cbaa6fcaefb45fca7d835dbecc8f94 to your computer and use it in GitHub Desktop.
Save klinyecviktor/f4cbaa6fcaefb45fca7d835dbecc8f94 to your computer and use it in GitHub Desktop.
passport.use(new LocalStrategy((async (username, password, done) => {
try {
const user = await User.getUserByUsername(username);
if (!user) return done(null, false, { message: 'Unknown User' });
const isMatch = await User.comparePassword(password, user.password)
if (isMatch) return done(null, userStore);
return done(null, false, { message: 'Invalid password' });
} catch ({message}) {
console.error(message);
}
})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment