Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

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

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

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

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

Comments

@bertho-zero
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor Author

It's perfectly fine

@bertho-zero
Copy link
Contributor Author

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants