You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c69dc5a
Browse filesBrowse the repository at this point in the historyBrowse files
fix(nextjs): keep the ID token claims in the session cookie and switch organizations without the in-memory session
The Next.js session lives in an HttpOnly JWT cookie, but organization switching,
the current-organization lookup and the ID-token fallback of the user profile
still went through the legacy Node client, whose session is a process-local
memory cache. After a server restart, on another serverless instance, or once
the middleware had refreshed the tokens in the Edge runtime, that cache was
empty or stale and those operations failed while the user was still signed in.
- Store the ID token claims (minus single-use protocol claims) in the session
cookie at sign-in, on organization switch and on refresh.
- Read them back in getDecodedIdToken(); keep the in-memory session only as a
fallback for cookies issued before this change.
- Perform the organization_switch grant directly with the access token from the
cookie and update the in-memory session best-effort afterwards.
- Align the getUser() fallback with the React SDK (ID token claims).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Organization switching, the current organization and the ID-token fallback of the user profile no longer depend on the in-memory session of the underlying Node client, which is empty after a server restart, on another serverless instance, or after the middleware refreshed the tokens in the Edge runtime. The claims of the ID token are now kept in the session cookie (single-use protocol claims such as `at_hash` and `nonce` are dropped), `getDecodedIdToken()` reads them from there, and the `organization_switch` exchange uses the access token from the cookie.
0 commit comments