[英]Socket.io and Passport.js
我試圖使用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)
我解決了有關護照版本的問題。我安裝了最新版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.