PYIC-7189 Invalidate repeat CRI callbacks #2919
Open
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.
Proposed changes
What changed
Clear the CRI OAuth session id as soon as we receive a successful callback for that CRI.
Why did it change
Previously we would only invalidate the CRI OAuth session id after processing the full CRI callback and a subsequent journey event.
For slow CRIs this can be a significant window of time (5-10s), and the user may get frustrated and either resubmit or refresh the page. This triggers a second CRI callback, however this callback will always fail:
This means that the second callback will trigger an error scenario, which may complete faster than the first (possibly successful) request, leaving the user on an error screen.
By invalidating the session immediately, we should significantly reduce this window (although it will still exist), and instead produce an INVALID_OAUTH_STATE error, which will render
pyi-attempt-recovery
, allowing the user to try and recover their state.The state they recover to will depend on the progress of the first callback: