Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT is not sent after socket reconnection #272

Closed
Mangatt opened this Issue Aug 15, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@Mangatt
Copy link

Mangatt commented Aug 15, 2016

I have stumbled upon strange behavior - after socket is disconnected and connected again, new realtime events does not contain JWT (hook.params.token) which renders all reconnect process useless (= you have to authorize user again manually).

What to do about this?

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Aug 15, 2016

At the moment have to store the token and send the authenticate event. When using the client this can be done with calling app.authenticate() again after a disconnect just like when the application is loading initially. The next version should probably try to do this automatically.

@tkornblit

This comment has been minimized.

Copy link

tkornblit commented Aug 19, 2016

I'm also running into this issue. I've even done the following:

this.app = feathers()
        .set("user", JSON.parse(localStorage.getItem('user')))
        .set("token", localStorage.getItem('token'))
        .configure(socketio(socket))
        .configure(hooks())
        .configure(authentication({storage: localStorage}))

Which I thought was going to be a clever hack.

The client-side hook picks it up successfully. But for some reason it's not available in the hook on the server side.

Using app.authenticate isn't going to work for me because i'm using the local authentication option and not JWT.

Any ideas?

@Mangatt

This comment has been minimized.

Copy link
Author

Mangatt commented Aug 19, 2016

@tkornblit I have solved this issue with following code:

const socket = io('http://localhost:3030/');

const app = feathers()
    .configure(hooks())
    .configure(socketio(socket))
    .configure(authentication({ storage: window.localStorage }));

socket.on('reconnect', () => {app.authenticate();});

Hope this helps.

@tkornblit

This comment has been minimized.

Copy link

tkornblit commented Aug 21, 2016

Thanks mate. This was helpful.

Tom Kornblit
Founder of Sage http://www.sagebots.com/
Personal Blog http://blog.tomkornblit.com/ | LinkedIn https://www.linkedin.com/in/tomkornblit | Twitter https://twitter.com/tkornblit

On Aug 19, 2016, at 2:17 AM, Mangatt notifications@github.com wrote:

@tkornblit https://github.com/tkornblit I have solved this issue with following code:

const socket = io('http://localhost:3030/');

const app = feathers()
.configure(hooks())
.configure(socketio(socket))
.configure(authentication({ storage: window.localStorage }));

socket.on('reconnect', () => {app.authenticate();});
Hope this helps.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub #272 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AB7b-YAUxpQXj5llLXrBe8bwtf3LBNnXks5qhUpwgaJpZM4JkXY3.

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Oct 25, 2016

Closing this in favor of feathersjs/authentication-client#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.