UPDATE
Req получилось передать при login
app.post('/login',urlencodedParser, (req, res, next) => {
passport.authenticate('local',req function(err, user) {
if (err) {
return next(err);
}
if (!user) {
return res.json({message:'loginOrPassword'});
}
req.logIn(user, function(err) {
if (err) {
return next(err);
}
return res.json({message:'welcome'});
});
})(req, res, next);
});
Passport-config
passport.use(
new LocalStrategy({passReqToCallback :true, usernameField: 'email'}, function(
req,
email,
password,
done
) {
console.log(email+ " "+password);
if(req.session.comeBack && (req.session.comeBack[1] && req.session.comeBack[2])){
email = req.session.comeBack[1];
password = req.session.comeBack[2];
}
console.log(email + " "+password);
Users.findAll({where:{email:email}}).then(function(row){
if (email === row[0].dataValues.email && password === row[0].dataValues.password) {
return done(null, {
id: row[0].dataValues.id,
email: row[0].dataValues.email,
password: row[0].dataValues.password,
});
} else {
}
return done(null, false);
});
})
);