Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/oauth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ export async function runLogin(
await (deps.saveAccountCredential ?? saveAccountCredential)(provider, opts.reauthAccountId, cred);
} else {
await (deps.saveCredential ?? saveCredential)(provider, cred, {
preserveIdentityless: provider === "kiro" && opts?.forceLogin === true,
preserveIdentityless: opts?.forceLogin === true,
});
}
if (provider !== "chatgpt") {
Expand Down
25 changes: 25 additions & 0 deletions tests/oauth-reauth-bind.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,31 @@ describe("OAuth account-scoped reauth", () => {
expect(getAccountCredential("kiro", set.activeAccountId)?.access).toBe("identified-access");
});

test("forced Kimi add-account preserves a legacy identity-less account", async () => {
await saveCredential("kimi", {
access: "legacy-access",
refresh: "legacy-refresh",
expires: Date.now() + 60_000,
});
const original = OAUTH_PROVIDERS.kimi.login;
OAUTH_PROVIDERS.kimi.login = async () => ({
access: "identified-access",
refresh: "identified-refresh",
expires: Date.now() + 60_000,
accountId: "new-kimi-user",
});
try {
await runLogin("kimi", {} as OAuthController, { forceLogin: true });
} finally {
OAUTH_PROVIDERS.kimi.login = original;
}

const set = getAccountSet("kimi")!;
expect(set.accounts).toHaveLength(2);
expect(set.accounts.some(account => account.credential.access === "legacy-access")).toBe(true);
expect(getAccountCredential("kimi", set.activeAccountId)?.access).toBe("identified-access");
});

test("non-force Kiro login upgrades a legacy identity-less slot in place", async () => {
await saveCredential("kiro", {
access: "legacy-access",
Expand Down
Loading