From 179ace23e164c8aee1986d680bdd7487f3764ede Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Thu, 27 Nov 2025 23:03:29 +0530 Subject: [PATCH] fix: sign upsert error (#25437) --- packages/features/auth/signup/handlers/calcomHandler.ts | 3 +++ packages/features/auth/signup/handlers/selfHostedHandler.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/features/auth/signup/handlers/calcomHandler.ts b/packages/features/auth/signup/handlers/calcomHandler.ts index dae38c2f95..0ea62c1c86 100644 --- a/packages/features/auth/signup/handlers/calcomHandler.ts +++ b/packages/features/auth/signup/handlers/calcomHandler.ts @@ -154,6 +154,7 @@ const handler: CustomNextApiHandler = async (body, usernameStatus) => { }, }); if (team) { + const organizationId = team.isOrganization ? team.id : team.parent?.id ?? null; const user = await prisma.user.upsert({ where: { email }, update: { @@ -166,12 +167,14 @@ const handler: CustomNextApiHandler = async (body, usernameStatus) => { update: { hash: hashedPassword }, }, }, + organizationId, }, create: { username, email, identityProvider: IdentityProvider.CAL, password: { create: { hash: hashedPassword } }, + organizationId, }, }); // Wrapping in a transaction as if one fails we want to rollback the whole thing to preventa any data inconsistencies diff --git a/packages/features/auth/signup/handlers/selfHostedHandler.ts b/packages/features/auth/signup/handlers/selfHostedHandler.ts index 5bfc23335c..69d88ccc23 100644 --- a/packages/features/auth/signup/handlers/selfHostedHandler.ts +++ b/packages/features/auth/signup/handlers/selfHostedHandler.ts @@ -88,6 +88,7 @@ export default async function handler(body: Record) { } } + const organizationId = team.isOrganization ? team.id : team.parent?.id ?? null; const user = await prisma.user.upsert({ where: { email: userEmail }, update: { @@ -100,12 +101,14 @@ export default async function handler(body: Record) { }, emailVerified: new Date(Date.now()), identityProvider: IdentityProvider.CAL, + organizationId, }, create: { username: correctedUsername, email: userEmail, password: { create: { hash: hashedPassword } }, identityProvider: IdentityProvider.CAL, + organizationId, }, });