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

Knock client does not allow changing of user #146

Open
isaachinman opened this issue May 20, 2024 · 0 comments
Open

Knock client does not allow changing of user #146

isaachinman opened this issue May 20, 2024 · 0 comments

Comments

@isaachinman
Copy link

We noticed some 403 logs in our application.

Long story short, this is a reproducible error that occurs because the Knock client, as a global singleton, is not correctly handling changing of user.

The teardown function is more or less useless.

If you first initialise a client with user-1, and then reauthenticate with user-2, the client will still attempt to fetch user-1, and will get a 403.

I assume this issue has not yet been reported because most of your customers use React context/hooks, or something.

For now we will work around this issue by putting the Knock client inside a zustand store itself, instead of treating it as a global singleton.

I would suggest two action steps:

  1. Expose a proper teardown function that actually does what it says, instead of only disconnecting a websocket
  2. Correctly handle subsequent .authenticate calls. The UserClient should ideally just be entirely recreated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant