From 34c03b1f73006edf95df1c9779b1119c7cececa2 Mon Sep 17 00:00:00 2001 From: Rakshit Kaintura Date: Mon, 27 Jul 2026 17:08:30 +0530 Subject: [PATCH] fix(auth): map oauth login to correct user id instead of account id (#3256) --- packages/auth/src/oauth-profile.test.ts | 4 +++- packages/auth/src/oauth-profile.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/auth/src/oauth-profile.test.ts b/packages/auth/src/oauth-profile.test.ts index bddcf1dda..84c842caa 100644 --- a/packages/auth/src/oauth-profile.test.ts +++ b/packages/auth/src/oauth-profile.test.ts @@ -75,7 +75,7 @@ describe("createProfileMapper", () => { expect(dbMock.update).toHaveBeenCalledTimes(1); expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" }); expect(result).toEqual({ - id: "legacy-user-id", + id: "user-1", name: "Legacy User", email: "legacy.user@example.com", image: "https://example.com/new.png", @@ -153,6 +153,7 @@ describe("createProfileMapper", () => { expect(dbMock.select).toHaveBeenCalledTimes(2); expect(result).toEqual({ + id: "user-1", name: "GitHub User", email: "github.user@example.com", image: "https://example.com/new.png", @@ -189,6 +190,7 @@ describe("createProfileMapper", () => { expect(dbMock.update).toHaveBeenCalledTimes(1); expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" }); expect(result).toEqual({ + id: "user-1", name: "Legacy User", email: "legacy.user@example.com", image: "https://example.com/new.png", diff --git a/packages/auth/src/oauth-profile.ts b/packages/auth/src/oauth-profile.ts index 8930530ca..31b7d91fe 100644 --- a/packages/auth/src/oauth-profile.ts +++ b/packages/auth/src/oauth-profile.ts @@ -186,7 +186,7 @@ export function createProfileMapper({ await normalizeExistingUserEmail(existingUser.id, existingUser.email, existingEmail); return { - ...(existingUser.accountId ? { id: existingUser.accountId } : {}), + id: existingUser.id, name: existingUser.name, email: existingEmail, image: image ?? existingUser.image,