0
试图了解 https://github.com/jaredhanson/passport/blob/master/lib/middleware/authenticate.js,在第57行不合逻辑的Passport身份验证方法的参数
我不明白为什么护照身份验证方法有4个参数:
module.exports = function authenticate(passport, name, options, callback){/*code*/}
在实践中它的使用是这样的:
passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' });
或
passport.authenticate('local', function(req, res));
那么在方法定义中第一个参数“护照”怎么不会干扰呢?由于策略名称是作为第一个参数传递的,因此它应该映射到passport而不是名称。
如果这是Python,我会告诉你第一个参数从表达式'passport.authenticate'接收到对象'passport'。 Javascript通常不会那样工作,但我不会惊讶地发现有人找到了一种方法来使它以这种方式工作。 – zwol