mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-23 23:02:17 +10:00
fix(auth): map oauth login to correct user id instead of account id (#3256)
This commit is contained in:
@@ -75,7 +75,7 @@ describe("createProfileMapper", () => {
|
|||||||
expect(dbMock.update).toHaveBeenCalledTimes(1);
|
expect(dbMock.update).toHaveBeenCalledTimes(1);
|
||||||
expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" });
|
expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" });
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
id: "legacy-user-id",
|
id: "user-1",
|
||||||
name: "Legacy User",
|
name: "Legacy User",
|
||||||
email: "legacy.user@example.com",
|
email: "legacy.user@example.com",
|
||||||
image: "https://example.com/new.png",
|
image: "https://example.com/new.png",
|
||||||
@@ -153,6 +153,7 @@ describe("createProfileMapper", () => {
|
|||||||
|
|
||||||
expect(dbMock.select).toHaveBeenCalledTimes(2);
|
expect(dbMock.select).toHaveBeenCalledTimes(2);
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
|
id: "user-1",
|
||||||
name: "GitHub User",
|
name: "GitHub User",
|
||||||
email: "github.user@example.com",
|
email: "github.user@example.com",
|
||||||
image: "https://example.com/new.png",
|
image: "https://example.com/new.png",
|
||||||
@@ -189,6 +190,7 @@ describe("createProfileMapper", () => {
|
|||||||
expect(dbMock.update).toHaveBeenCalledTimes(1);
|
expect(dbMock.update).toHaveBeenCalledTimes(1);
|
||||||
expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" });
|
expect(dbMock.updateSet).toHaveBeenCalledWith({ email: "legacy.user@example.com" });
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
|
id: "user-1",
|
||||||
name: "Legacy User",
|
name: "Legacy User",
|
||||||
email: "legacy.user@example.com",
|
email: "legacy.user@example.com",
|
||||||
image: "https://example.com/new.png",
|
image: "https://example.com/new.png",
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ export function createProfileMapper<TProfile extends OAuthProfile>({
|
|||||||
await normalizeExistingUserEmail(existingUser.id, existingUser.email, existingEmail);
|
await normalizeExistingUserEmail(existingUser.id, existingUser.email, existingEmail);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...(existingUser.accountId ? { id: existingUser.accountId } : {}),
|
id: existingUser.id,
|
||||||
name: existingUser.name,
|
name: existingUser.name,
|
||||||
email: existingEmail,
|
email: existingEmail,
|
||||||
image: image ?? existingUser.image,
|
image: image ?? existingUser.image,
|
||||||
|
|||||||
Reference in New Issue
Block a user