fix(oauth): keep multiple Kimi accounts via JWT user_id#156
Closed
Wibias wants to merge 1 commit into
Closed
Conversation
Kimi login stored no accountId, so saveCredential replaced the active slot and a second login wiped the first. Map JWT user_id/sub onto accountId (email lowercased when present).
lidge-jun
added a commit
that referenced
this pull request
Jul 19, 2026
… across tokens Repairs for community PR #156 absorb (source head a6d824e), Sol review findings: - saveCredential: when an identified credential arrives and the provider's ACTIVE row is identity-less (pre-fix legacy), upgrade that row in place instead of appending — the stale row previously stayed selectable and could re-refresh into a duplicate of the same human. Distinct users still append. - identityFromKimiTokens: user_id is now preferred ACROSS both tokens (access.user_id ?? refresh.user_id ?? access.sub ?? refresh.sub) so a refresh-token user_id beats an access-token sub, matching the documented preference. - Wiring test: refreshKimiToken (production parseTokenPayload path) asserted to carry JWT identity, so removing the identity spread can no longer pass. - Migration + cross-token + wiring activation tests added; oauth-store-multi contract suite still green (13 pass). Co-authored-by: Wibias <37517432+Wibias@users.noreply.github.com>
Owner
|
Thanks — the root cause (identity-less Kimi tokens replacing the active slot) and the JWT user_id extraction were right, and it's landed on
Full suite green (3,087 tests). Closing in favor of the dev-landed commits; ships with the next release. |
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.
Summary
accountId/email.saveCredentialonly appends when identity is present; identity-less providers replace the active account in place.accountIdfromuser_id(fallbacksub), plus optional lowercasedemail. Distinct users append; sameuser_idupserts.Notes
Test plan
bun test tests/kimi-oauth-identity.test.ts tests/oauth-store-multi.test.ts