passport.use( new BasicStrategy(async (email, password, cb) => { const user = (await db.query('SELECT * FROM account WHERE email=$1', [ email ])).rows[0] if (!user) return cb(null, false) if (!user.activated) return cb(null, false) const passwordValid = await bcrypt.compare(password, user.password) if (!passwordValid) return cb(null, false) let token = jwt.sign( { // jwt claims go here // this includes standard claims like iat (issued at) // as well as any custom data you would like to include email: email }, process.env.JWT_SECRET ) return cb(null, token) }) )
passport.use( new BasicStrategy(async (email, password, cb) => { const user = (await db.query('SELECT * FROM account WHERE email=$1', [ email ])).rows[0] if (!user) return cb(null, false) if (!user.activated) return cb(null, false) const passwordValid = await bcrypt.compare(password, user.password) if (!passwordValid) return cb(null, false) let token = jwt.sign( { // jwt claims go here // this includes standard claims like iat (issued at) // as well as any custom data you would like to include email: email }, process.env.JWT_SECRET ) return cb(null, token) }) )