找不到 Passport 身份验证中间件资源

Passport authentiation middleware res not found

我有以下代码库

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 returns 错误格式如

userController.ValidateLogin = function(req,res,userDetails) {
    return res.send({ Status:403, Msg: "Not allowed" });
}

但它说 res.send 不是一个函数,因为有 res undefined ,如何发送 res 以便我在 return

中有这种消息

您不能从配置中间件发送响应(它只能用于我们验证用户的护照配置)。您需要对用户进行身份验证和验证,然后 return 返回,以下代码可能对您有所帮助,

userController.ValidateLogin = function(req,res,callback) {
    return callback({ Status:403, Msg: "Not allowed" });
}