how to load the local strategy on the express ??
i tried console.log my passport stragetgi fucntion on my key/passport folder
here is on the key/folder codes
import LocalStrategy from 'passport-local'
import bcrypt from 'bcryptjs'
import models from '../models'
const {
Players,
Clubs,
Competetions
} = models
export default function(passport) {
passport.use(
new LocalStrategy(
function(email, password, done) {
Players.findOne({
where: {
"email": email
}
})
.then(data => {
if (!data) {
return done(null, false, {
message: 'That email is not registered'
})
}
bcrypt.compare(password, user.password, (err, isMatch) => {
if (err) throw err;
if (isMatch) {
return done(null, user);
} else {
return done(null, false, {
message: 'Password incorrect'
})
}
})
}).catch(err => console.log(err))
}
)
)
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
Players.findById(id)
.then(data => {
if(data){
done(null, data)
}
})
.catch(err => {
done(err, null)
})
})
}
// passport.serializeUser(function(user, done) {
// done(null, user.id);
// });
//
// passport.deserializeUser(function(id, done) {
// Players.findById(id, function(err, user) {
// done(err, user);
// });
// });
i am i write long callback in the promise ?? 0
1 I am building an app that requires authentication during login and for that I have used passport(passport-local). The app does not run for the login part and the last option available after removing all syntax errors is that the way in which I am using passport(as given in their docs) is for mongoose while I am using sequelize. Can someone please tell how to rectify my passport.js file so that it works fine for sequelize as well? (using mysql through sequelize; database is already populated) here is my passport.js file