-
Notifications
You must be signed in to change notification settings - Fork 81
Refresh socket.request.user when user authenticates #132
Comments
I've had this issue for quite some time as well. A clean solution would be greatly appreciated, as this makes this library not the best choice for SPAs. |
ж Ихва
On Mar 26, 2017 4:13 AM, "Alex Wohlbruck" <[email protected]> wrote:
As of right now, when an unauthenticated user goes my site and then logs
in, the socket.request.user variable remains empty for each emit afterward,
unless the page is refreshed (Using an Angular single page app). How do I
get the updated data when a user logs in or out?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#132>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAEuN6V_ERGRPLUW-KbIeUHjWiPhz9_uks5rpbu4gaJpZM4MpRrw>
.
|
Make sure you initiate a new socket.io conneciton after the user logins. In new versions of socket.io: // new socket.io:
var socket = io.connect(socketUrl,{'forceNew': true });
// old socket.io:
var socket = io.connect(URL, {'force new connection': true }); You need to force a new, otherwise socket.io reuses the connection initiated before authentication. |
Okay, that works. Should I also disconnect after they sign out? |
Hello team, I know this issue is old but I would appreciate if we could give it a bit more attention. Could it be possible to integrate a method bound to the socket that updates the stored values of the session user? Currently, PasseportJS uses the req.login function that allows you to update the user informations bound to the request.user object. It is very usefull in a SPA when a user goes to his settings and updates important information. Don't need to reload browser or anything. I believe this library would profit very positively from a similar approach. -Thank you |
Litle update: After looking online if there was a method bound directly to socket.io to refresh the handshake I found this:
|
As of right now, when an unauthenticated user goes my site and then logs in, the socket.request.user variable remains empty for each emit afterward, unless the page is refreshed (Using an Angular single page app). How do I get the updated data when a user logs in or out?
The text was updated successfully, but these errors were encountered: