Skip to content

fix: keep state and url_state on the stored user - #2480

Open
artbom wants to merge 1 commit into
authts:mainfrom
artbom:fix/persist-user-state
Open

artbom wants to merge 1 commit into
authts:mainfrom
artbom:fix/persist-user-state

Conversation

@artbom

@artbom artbom commented Nov 4, 2026 •

Copy link
Copy Markdown

Fixes #2457

User.toStorageString() never wrote state or url_state, so after the first trip through storage, getUser() returned a user without them. Refresh-token renewal then built its RefreshState from that stored user. RefreshState had no url_state field at all, so silent renew lost both.

This stores them with the user as user_state and url_state, matching the other snake_case keys. fromStorageString() maps user_state back to the constructor's userState. RefreshState now takes url_state too, and validateRefreshResponse copies it onto the response next to userState.

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 User storage round trip, storeUser() then getUser(), and a refresh-token signinSilent(). That last one only mocks exchangeRefreshToken, so the real validateRefreshResponse runs. All three fail without the change, and npm test passes with 575 tests.

Checklist

  • This PR makes changes to the public API. RefreshState gets an optional url_state, and I updated the API report.
  • I have included links for closing relevant issue numbers

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
artbom force-pushed the fix/persist-user-state branch from c608521 to f452e7a Compare November 4, 2026 17:33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getUser() and refresh-token silent renew lose custom state and url_state

1 participant