passport.use(new Strategy( function (username, password, cb) { Users.findOne({username: username, password:password}, function (err, user) { return cb(null, user); }); }));
passport.use( new Strategy(function(username, password, cb) { User.findAll({ where: { username: username }, }) .then(user => { user = user[0]; if (!user) { return cb(null, false); } if (!bcrypt.compareSync(password, user.password)) { return cb(null, false); } return cb(null, user); }) .catch(err => { return cb(err); }) }) );
passport.use(new LocalStrategy({ usernameField: 'email', session: false, }, function(email, password, cb) { db.users.findByEmail(email, function(err, user) { if (err) { return cb(err); } if (!user) { return cb(null, false); } if (user.password != password) { return cb(null, false); } return cb(null, user); }); } ));
// Configure the local strategy for use by Passport. // // The local strategy require a `verify` function which receives the credentials // (`username` and `password`) submitted by the user. The function must verify // that the password is correct and then invoke `cb` with a user object, which // will be set at `req.user` in route handlers after authentication. passport.use(new Strategy( function(username, password, cb) { db.users.findByUsername(username, function(err, user) { if (err) { return cb(err); } if (!user) { return cb(null, false); } if (user.password != password) { return cb(null, false); } return cb(null, user); }); }));
// Configure the local strategy for use by Passport. // // The local strategy require a `verify` function which receives the credentials // (`username` and `password`) submitted by the user. The function must verify // that the password is correct and then invoke `cb` with a user object, which // will be set at `req.user` in route handlers after authentication. passport.use( new Strategy((username, password, cb) => { db.users.findByUsername(username, (err, user) => { if (err) { return cb(err); } if (!user) { return cb(null, false); } if (user.password !== password) { return cb(null, false); } return cb(null, user); }); }) );