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

How to reconnect socket with cookie after page refresh ? #372

Closed
bertho-zero opened this Issue Dec 14, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@bertho-zero
Copy link
Contributor

bertho-zero commented Dec 14, 2016

Hi,

How to automatically connect the socket using the accessToken in the cookie after refreshing the page? I use version 1 of feathers-authentication.

It would be practical to be able to:

app.io.use(authentication.socket.authenticate());
@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Dec 14, 2016

Right now you have to call feathersClient.authenticate() to make this happen. Sockets are flagged as authenticated from the server side once they pass validation.

@bertho-zero

This comment has been minimized.

Copy link
Contributor Author

bertho-zero commented Dec 14, 2016

It's perfectly fine

@bertho-zero

This comment has been minimized.

Copy link
Contributor Author

bertho-zero commented Dec 16, 2016

Finally I created this socket.io middleware: https://gist.github.com/bertho-zero/5cdeabb77be98bc159b1e5d75c6af429

It is used like this:

app.io.use(socketAuth(app));

If I remove this line (gist#L17) I have an error from here: https://github.com/feathersjs/feathers-authentication/blob/master/src/socket/handler.js#L38

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.