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

🐛 Fix auth redirect issue after logout #485

Merged
merged 1 commit into from
Oct 20, 2024

Conversation

aaronleopold
Copy link
Collaborator

This PR should fix a bit of an annoying bug which caused an overload of history pushes after login in a very specific scenario. At first, I thought this was just a quirk of having 3-4 testing instances of Stump with competing cookies causing flakes. The issue seemed to present when you manually log out and try to re-auth immediately.

The actual cause was that the query cache for fetching the logged in user did not clear correctly after logout. A logout triggered a refetch, which returned a 401. When you re-logged in (without a full browser refresh) that 401 remained the non-stale result so you immediately would get smacked back into auth, and then back, and then back again, etc.

The fix was really a mix of a few things:

  • Update the delete cookie response for 401 API errors to have SameSite attribute
    • Make the logout API response encourage cookie deletion
  • Remove all navigation from effects (in relevant auth flow)
  • Ensure the me query is re-fetched before navigating to the page which would otherwise send you back to /auth

Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 4.76190% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
apps/server/src/routers/api/v1/auth.rs 0.00% 20 Missing ⚠️
Files with missing lines Coverage Δ
apps/server/src/config/session/utils.rs 29.03% <100.00%> (ø)
apps/server/src/routers/api/v1/auth.rs 0.00% <0.00%> (ø)

@aaronleopold aaronleopold marked this pull request as ready for review October 20, 2024 00:45
@aaronleopold aaronleopold merged commit 90805f9 into experimental Oct 20, 2024
8 checks passed
@aaronleopold aaronleopold deleted the al/fix-auth-edge-case branch October 20, 2024 00:46
@aaronleopold aaronleopold mentioned this pull request Dec 4, 2024
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

Successfully merging this pull request may close these issues.

1 participant