re: #Help with passport and postgresql VIEW POST


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);

  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, 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.

code of conduct - report abuse