【发布时间】:2018-06-06 04:48:52
【问题描述】:
我有以下代码库
passport.use(new LocalStrategy({
usernameField: 'emailAddress',
passwordField: 'password',
passReqToCallback: true
},
function(req,username, password, next) {
var res =""; // this is the real issue, I don't know where to find res, or what should I initialize to re
console.log('psprt val');
userController.ValidateLogin(req,res,function(userDetails){
req.user = userDetails;
return next(null,userDetails);
});
}));
userController.ValidateLogin 以类似
的格式返回错误userController.ValidateLogin = function(req,res,userDetails) {
return res.send({ Status:403, Msg: "Not allowed" });
}
但它说 res.send 不是函数,因为有 res undefined ,如何发送 res 以便我有这种消息作为回报
【问题讨论】:
-
告诉我们有问题的代码行
return res.send({ Status:403, Msg: "Not allowed" });在哪里。向我们展示usercontroller.ValidateLogin()的代码。这就是问题所在。 -
这是来自验证登录功能
-
是的,给我们看一下那个函数的代码吧!
-
粘贴
ValidateLogin()函数的代码。 -
你可以看到我在上面给出了 res=' ',因为我没有 res
标签: node.js express passport.js middleware passport-local