Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const User = require('../models/user')
- const LocalStrategy = require('passport-local').Strategy
- const strategy = new LocalStrategy(
- {
- usernameField: 'username'
- },
- function (username, password, done) {
- User.findOne({ 'local.username': username }, (err, userMatch) => {
- if (err) {
- return done(err)
- }
- if (!userMatch) {
- return done(null, false, {message: "Incorrect username"})
- }
- if (!userMatch.checkPassword(password)) {
- return done(null, false, {message: 'Incorrect passsword'})
- }
- return done(null, userMatch)
- })
- }
- )
- module.exports = strategy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement