fix: avoid reinitiating partial authentication flow when user is already authenticated #962
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.
Fixes: #922, and possibly some others. Influenced by authts/oidc-client-ts#402.
TLDR:
Personally what I discovered was that upon redirect from login, we still had the auth params in our query string. So if one were to reload the page or browse forward a page then hit the back button, we'd encounter the same thing. hasCodeInUrl() would pass which would trigger an invalid auth flow again. Therefore, I simply add a check that not only does
hasCodeInUrl
check out, but also that userManager doesn't actively have a user already authenticated.I feel like I might be missing something here since I'm not very aware of all the possible authentication flows that are being used with oidc-react. If I could get some additional eyes on this I'd greatly appreciate it.