相关疑难解决方法(0)

Passport身份验证回调未通过req和res

这个身份验证工作正常,我得到一个重定向:

server.post(authPostRoute, passport.authenticate(
    'local'
    , { successRedirect: '/', failureRedirect: '/login' }
));     
Run Code Online (Sandbox Code Playgroud)

调用回调后,此身份验证会挂起:

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

这记录了以下内容:

{ '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 }
Run Code Online (Sandbox Code Playgroud)

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

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

  strategy.success = function(user, info) {
    if (callback) {
      return callback(null, user, info);
    }
Run Code Online (Sandbox Code Playgroud)

不传递这些参数.我究竟做错了什么?

authentication node.js express passport.js

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

authentication ×1

express ×1

node.js ×1

passport.js ×1