我目前有中间件检查用户是否已登录,如下所示。
middlewareObj.isLoggedIn = function(req,res,next){
if(req.isAuthenticated()){
return next();
}
console.log("error", "You need to be logged in!");
req.session.returnTo = req.path;
console.log(req.session.returnTo)
res.redirect("/login");
};
我希望功能如下......
isLoggedIn(param);
所以我可以用类似于下面显示的方式检查其他要求
middlewareObj.isLoggedIn(Param) = function(req,res,next){
if(req.isAuthenticated() && Param){
return next();
}
console.log("error", "You need to be logged in!");
req.session.returnTo = req.path;
console.log(req.session.returnTo)
res.redirect("/login");
};