很简单的应用,对于所有要打开的网页,包含一些static page,先看下有没有login,
没有的话跳到login页面。这么写法行吗?
function isLoggedIn(req, res, next) {
// if user is authenticated in the session, carry on
if (req.isAuthenticated())
return next();
// if they aren't redirect them to the home page
res.redirect('/login');
}
app.get('*', isLoggedIn, function(req, res) {
......
});
谢谢!