【问题标题】:Socket.io and Passport.jsSocket.io 和 Passport.js
【发布时间】:2014-07-16 15:51:49
【问题描述】:

我正在尝试使用 Socket.io 和 Passport.js,而猫鼬我使用了这个 https://github.com/jfromaniello/passport.socketio 和我的代码

var cookieParser;
    cookieParser = express.cookieParser('supersecret');
var  session = require('express-session')
    ,RedisStore = require('connect-redis')(session);

在 route.js 中

      sio.set('authorization', passportSocketIo.authorize({
          cookieParser: connect.cookieParser,
          key: 'session_secret',         
        secret: 'supersecret',    
        store: new RedisStore,     
        success: onAuthorizeSuccess,  
        fail: onAuthorizeFail,   
    }));

    function onAuthorizeSuccess(data, accept) {
        console.log('successful connection to socket.io');


        accept(null, true);
    }

    function onAuthorizeFail(data, message, error, accept) {
        if (error)
            throw new Error(message);
        console.log('failed connection to socket.io:', message);

        // We use this callback to log all of our failed connections.
        accept(null, false);
    }

});

我收到此错误。

     return done(e);
         ^
 TypeError: object is not a function
  at pass (/Users/ANTEGRUP/Desktop/passport-local-  master/node_modules/passport/lib/passport/index.js:287:14)
at Passport.serializeUser (/Users/ANTEGRUP/Desktop/passport-local-master/node_modules/passport/lib/passport/index.js:289:5)
at IncomingMessage.req.login.req.logIn (/Users/ANTEGRUP/node_modules/passport/lib/http/request.js:48:29)
at Context.delegate.success (/Users/ANTEGRUP/Desktop/passport-local-master/node_modules/passport/lib/passport/middleware/authenticate.js:194:13)
at Context.actions.success (/Users/ANTEGRUP/Desktop/passport-local-master/node_modules/passport/lib/passport/context/http/actions.js:21:25)
at verified (/Users/ANTEGRUP/Desktop/passport-local-master/node_modules/passport-local/lib/passport-local/strategy.js:83:10)
at Object.ondone (/Users/ANTEGRUP/Desktop/passport-local-master/node_modules/passport-local-mongoose/lib/passport-local-mongoose.js:89:24)

【问题讨论】:

  • 发布堆栈跟踪。

标签: javascript node.js socket.io passport.js


【解决方案1】:

我解决了它关于护照版本的问题。我安装了最新版本。

【讨论】:

    猜你喜欢
    • 2023-03-15
    • 2016-09-10
    • 2023-03-09
    • 2018-01-08
    • 2014-03-22
    • 2019-08-16
    • 2014-03-21
    • 2013-06-11
    • 1970-01-01
    相关资源
    最近更新 更多