I am using passportjs, express 4, socket.io and to connect passportjs with socket i have added the passport.socketio with connect-mongo
as Session Store. I saw in many posts that i have to avoid cors use. So when i use in client side code: io.connect('/');
, none of functions is called(success/fail). When i use io.connect('http://localhost:8565');
, fail function get called with Message: "No session found".
Store:
var store = new (require("connect-mongo")(session))({url: "mongodb://localhost/databaseName"});
Session:
var sessionMiddleware = session({
key: 'your.sid-key',
secret: 'reallyawesomesecret',
resave: false,
saveUninitialized: true,
cookie: { maxAge: (365 * 24 * 60 * 60) },
rolling: true,
store: store
});
Passport.socketio:
io.use(passportSocketIo.authorize({
cookieParser: cookieParser,
key: 'your.sid-key',
secret: 'reallyawesomesecret',
store: store,
success: onAuthorizeSuccess,
fail: onAuthorizeFail
}));
Do i have to do something with the "key:'your.sid-key'," ? or i miss something else?
Inside function failed error get value false
and data.isAuthenticated()
is true
, but data.user
have {logged_in: false}
.