Passport身份validationcallback不传递req和res

这个身份validation正常工作,我得到一个redirect:

server.post(authPostRoute, passport.authenticate( 'local' , { successRedirect: '/', failureRedirect: '/login' } )); 

这个authentication在呼叫回叫后挂起:

 server.post(authPostRoute, passport.authenticate( 'local' , function(){ console.log('Hitting the callback'); console.log(arguments)} )); 

这logging了以下内容:

 { '0': null, '1': { id: [Getter/Setter], firstName: [Getter/Setter], lastName: [Getter/Setter], email: [Getter/Setter], addedOn: [Getter/Setter], active: [Getter/Setter], password: [Getter/Setter] }, '2': undefined } 

但在整个文档( http://passportjs.org/guide/authenticate/ )看起来好像它通过req和res,但它显然不是。 然后调用callback的代码:

node_modules \护照\ LIB \中间件\ authenticate.js

  strategy.success = function(user, info) { if (callback) { return callback(null, user, info); } 

不通过这些参数。 我究竟做错了什么?

好的,我正在努力取消我的自定义身份validation,并用护照取代了昨天的9个小时。 在让node-orm在请求之外暴露模型并处理sorting的stream程之间,我有点被烧毁了。 代码示例是准确的,我只需要仔细阅读:

 // traditional route handler, passed req/res server.post(authPostRoute, function(req, res, next) { // generate the authenticate method and pass the req/res passport.authenticate('local', function(err, user, info) { if (err) { return next(err); } if (!user) { return res.redirect('/'); } // req / res held in closure req.logIn(user, function(err) { if (err) { return next(err); } return res.send(user); }); })(req, res, next); }); 

启用passReqToCallback在callback中获取请求。 喜欢这个:

 passport.use(new FacebookStrategy({ clientID: '555555555555555', clientSecret: '555555555555555555555', callbackURL: "http://localhost:3000/auth/facebook/callback", enableProof: false, passReqToCallback: true }, // The request will be provided as 1st param function(req, accessToken, refreshToken, profile, done) { });...