Repository navigation
Conversation
User.toStorageString() left out state and url_state, so getUser() returned a user without them after the first storage round trip. Refresh-token renewal then built its RefreshState from that stripped user, and RefreshState had no url_state at all. - store state and url_state with the user - carry url_state through RefreshState into the refreshed user Fixes authts#2457
artbom
force-pushed
the
fix/persist-user-state
branch
from
November 4, 2026 17:33
c608521 to
f452e7a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #2457
User.toStorageString()never wrotestateorurl_state, so after the first trip through storage,getUser()returned a user without them. Refresh-token renewal then built itsRefreshStatefrom that stored user.RefreshStatehad nourl_statefield at all, so silent renew lost both.This stores them with the user as
user_stateandurl_state, matching the other snake_case keys.fromStorageString()mapsuser_stateback to the constructor'suserState.RefreshStatenow takesurl_statetoo, andvalidateRefreshResponsecopies it onto the response next touserState.Users stored by an older version still load, just without
state, same as today. The state already gets serialized into the state store during signin, so storing it with the user doesn't ask anything new of it.I added three tests: a
Userstorage round trip,storeUser()thengetUser(), and a refresh-tokensigninSilent(). That last one only mocksexchangeRefreshToken, so the realvalidateRefreshResponseruns. All three fail without the change, andnpm testpasses with 575 tests.Checklist
RefreshStategets an optionalurl_state, and I updated the API report.