It depends on what you're using to talk to Postgres. Here's some boilerplate I use with Massive and bcrypt:
const db = await massive(config.database); passport.serializeUser((user, done) => { done(null, user.user_id); }); passport.deserializeUser((userId, done) => { db.users.findOne(userId).then(user => { if (!user) { return done(null, false); } return done(null, user); }).catch(done); }); passport.use(new LocalStrategy({ usernameField: 'email', passwordField: 'password' }, async (username, password, done) => { const user = await db.users.findOne({email: username}); if (user) { const match = await bcrypt.compare(password, user.password); if (match) { return done(null, user); } } return done(null, false); }));
If you're not using Massive, you'd need to change each invocation involving db.
db
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It depends on what you're using to talk to Postgres. Here's some boilerplate I use with Massive and bcrypt:
If you're not using Massive, you'd need to change each invocation involving
db
.