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

🪟 🎉 Verify auth status on tab focus #21175

Merged
merged 7 commits into from
Jan 12, 2023

Conversation

teallarson
Copy link
Contributor

@teallarson teallarson commented Jan 9, 2023

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.

@octavia-squidington-iv octavia-squidington-iv added the area/frontend Related to the Airbyte webapp label Jan 9, 2023
@teallarson teallarson marked this pull request as ready for review January 9, 2023 20:37
Copy link
Contributor

@josephkmh josephkmh left a 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

@teallarson
Copy link
Contributor Author

@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.

@teallarson teallarson enabled auto-merge (squash) January 12, 2023 21:36
@teallarson teallarson merged commit 80f3c4e into master Jan 12, 2023
@teallarson teallarson deleted the teal/redirect-to-login-for-401 branch January 12, 2023 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend Related to the Airbyte webapp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants