🐛 Fix auth redirect issue after logout #485
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
SameSite
attributelogout
API response encourage cookie deletionme
query is re-fetched before navigating to the page which would otherwise send you back to/auth