-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
🪟 🎉 Verify auth status on tab focus #21175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution - works well!
Just noticed while I was testing that we have a similar problem when logging in. If you have two tabs open to the login (or signup) page, then authenticate in one of them, the other one would ideally also automatically log you in. One more thing we could add is a similar mechanism in src/packages/cloud/views/auth/Auth.tsx
to redirect users from unauthenticated routes (login, signup) to the authenticated routes.
I just created another ticket for the login issue: https://github.com/airbytehq/airbyte-cloud/issues/3992
@josephkmh that turned out to be fairly trivial to support in this PR as well, and falls under the category "verifying auth on tab focus" so I threw it in here. I also adjusted the logic for the redirect URL so this flow also redirects users to the page they came from when logged back in. |
What
Closes airbytehq/airbyte-cloud#3735 and airbytehq/airbyte-cloud#3992
Previously, a user could have two tabs open, logout in one, and could still click in the UI in their other (now out of date) tab and eventually see a vague/ominous "You do not have permissions" error.
Now, they are simply redirected to login upon tab focus.
How
Adds a useEffect() with a focus listener to our AuthService that watches for auth status changes whenever the window gains focus.