-
Notifications
You must be signed in to change notification settings - Fork 81
"Passport was not initialized" when using Passport 0.3.0 and Socket.io 1.3.6 #110
Comments
I get the same error. I'm using:
@patrickpilch Were you able to find a fix? |
Are you using the session middleware from express? |
@jfromaniello I am using express-session, if that's what you are asking. |
I had the same issue, I ended up downgrading to the packages listed in I then got a new error saying it was unable to find the provided session ID. That turned out to be an unrelated issue which occurred because I was pointing to |
@willshiao var session = require('express-session');
var sessionMiddleware = session({
store: sessionStore,
secret: 'such secret wow',
resave: false,
saveUninitialized: false
});
sockets.use(function(socket, next) {
sessionMiddleware(socket.request, socket.request.res, next);
}); |
Any progress on this issue? It doesn't seem to happen consistently (that is, somehow not every time - but definitely frequently) and is preventing me from being able to use passport 0.3.x and passport.socketio 3.6.x. If there is no plan to address it, that would be useful to know. Thanks! |
yeah, i really need to get this figured out. I have a few apps this is happening on. going to be looking into it much deeper this week and i'll post back if I can figure it out. |
I am also having this problem. I added some debugging code to the library and at the point that this error is thrown So Passport version: 0.3.2 |
That's not an unrelated issue but most of the time the reason of this specific issue. This module uses the passport session and in order to do that you need to verify that the browser is sending the cookies on the handshake. One of the reasons where the browser will not send the cookie is because you are using different domains, like |
My problems were also related to cross-domain cookies. I resolved this problem by using the CORS workaround from the Readme. I see in the code that you have an error message telling people to do just that, but for whatever reason I never hit that. |
I encounter the same issue as @dpieri did. So I look down to the detail, I found that if you using CORS request here. I tried several times and found that the object named passport might not always in the session object. This might cause by some changes in the newer version of passport, I will go check it. |
this is old question, but the problem is your are missing passport.serializeUser and passport.deserializeUser passport uses deserializeUser to update user in session object. |
I'm getting this error as ewll. I tried using 127.0.0.1 in my browser as well. The app seems to run on a server but not locally. |
I used this too and replaced won't use this library |
I am unable to get this library to work properly. My authorization failure callback is always called from the library's index.js file at line 75
Here is the code related to my setup
The text was updated successfully, but these errors were encountered: