且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

护照socketio打破护照实施?

更新时间:2023-12-04 14:41:52

更新:只需确保使用与passport-socketio 模块使用相同版本的passport,目前这是0.2.0 版,您可能还需要升级您的passport-facebook 模块

update: just make sure to use the same version of passport as the passport-socketio module is using, currently this is version 0.2.0, you might have to upgrade your passport-facebook module as well

旧帖子:

我遇到了同样的问题并通过更改passport-socket.io index.js文件解决了这个问题:

I had the same problem and solved this by changing the passport-socket.io index.js file:

var defaults = {
passport:     require('passport'),
key:          'connect.sid',
secret:       null,
store:        null,
success:      function(data, accept){accept(null, true)},
fail:         function(data, message, critical, accept){accept(null, false)}

};

将此默认配置更改为:

var defaults = {
passport:     null,
key:          'connect.sid',
secret:       null,
store:        null,
success:      function(data, accept){accept(null, true)},
fail:         function(data, message, critical, accept){accept(null, false)}

};

当然,这只有在您像目前一样传入自己的护照对象时才有效.问题与需要覆盖 req.login 函数的护照模块有关的passport-socketio有关,我明天会更好地看看到底出了什么问题.

Of course, this will only work if you pass in your own passport object like you are currently doing. The problem has something to do with passport-socketio requiring the passport module which overwrites the req.login function, I'll have a better look tomorrow to figure out exactly what is going wrong.