I use the module passport to create authentication with session .. But since express v4 , there is no more tutorial .. and my authentication doesn't work , in effect in my function that verify if the user is authenticated , the req.user is always undefined and req.isAuthenticated is false !
exports.ensureAuthenticated = function(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/login');
}
app.use(connect.logger('dev'));
app.use(express.static('public'));
app.use(connect.cookieParser());
app.use(bodyParser());
app.use(connect.cookieSession({ secret: 'keyboard cat', cookie: { secure: true }}));
app.use(passport.initialize());
app.use(passport.session());
Any solution ?