I had a problem previously with passport authentication but solved it and now when I login with right credentials, flash messages don't work, but when I log with wrong credentials, they work. What could it be?
router.post('/login', passport.authenticate('local', { failureFlash: true, successFlash: true, failureRedirect: '/login' , successRedirect: "/campgrounds"}), (req, res) => {
req.flash('success', 'welcome back!');
});
module.exports = router;
And a part of passport code
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
passport.use(new localStrategy(User.authenticate()));
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
done(err, user);
});
})
question from:
https://stackoverflow.com/questions/65924540/why-i-cant-send-flash-messages-in-passport-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…