2
我有app.html
在一个公共文件夹中,它正在提供静态文件来表达。允许访问html页面只能登录用户
我已使用here的代码。
但是从视图文件夹而不是profile.ejs
(根据链接中的代码),我想从公用文件夹内提供app.html
。
app.get('/app.html', isLoggedIn, function(req, res) {
res.render('app.html'/*, {
user : req.user // get the user out of session and pass to template
}*/);
console.log("APP.HTML");
});
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('/');
}
不过,这并不限制使用权限的用户loggedIn
,我能直接注销以及之后访问它。
这里有什么问题?
工作。万分感谢 。 –