fix(api): clean session cookies only for invalid refresh token #2049
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.
I've checked how the v8 and account-web process rejected requests for refreshing the token with the following code (almost identical code). The code only checks if the response status code is higher or equal to 400.
Moreover, I have not found any code, which cleans up the cookies when refreshing the token fails. We added this because we had a bug in Safari with setting the correct cookie expiration date (some time ago). We can still keep the cleanup, but it should be done only if the server explicitly responds with 400 code - so we are sure that something is wrong with the cookie itself.
Without the fix, if a user loses internet connection on that call, the
catch
will clean up the session.