I am having troubles understanding why passportjs does not provide this by default, but I have to create my own function like:function loggedIn(req, res, next) { if (req.user) { next(); } else { res.redirect('/login'); } }and use it as a middleware in the paths I want to protect:app.get('/myendpoint', loggedIn, function(req, res, next) { // my handler }); Why?
Submitted January 17, 2018 at 11:50AM by honestserpent
No comments:
Post a Comment