Skip to content

Commit 179ace2

Browse files
authored
fix: sign upsert error (calcom#25437)
1 parent 3af6fee commit 179ace2

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/features/auth/signup/handlers/calcomHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ const handler: CustomNextApiHandler = async (body, usernameStatus) => {
154154
},
155155
});
156156
if (team) {
157+
const organizationId = team.isOrganization ? team.id : team.parent?.id ?? null;
157158
const user = await prisma.user.upsert({
158159
where: { email },
159160
update: {
@@ -166,12 +167,14 @@ const handler: CustomNextApiHandler = async (body, usernameStatus) => {
166167
update: { hash: hashedPassword },
167168
},
168169
},
170+
organizationId,
169171
},
170172
create: {
171173
username,
172174
email,
173175
identityProvider: IdentityProvider.CAL,
174176
password: { create: { hash: hashedPassword } },
177+
organizationId,
175178
},
176179
});
177180
// Wrapping in a transaction as if one fails we want to rollback the whole thing to preventa any data inconsistencies

packages/features/auth/signup/handlers/selfHostedHandler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export default async function handler(body: Record<string, string>) {
8888
}
8989
}
9090

91+
const organizationId = team.isOrganization ? team.id : team.parent?.id ?? null;
9192
const user = await prisma.user.upsert({
9293
where: { email: userEmail },
9394
update: {
@@ -100,12 +101,14 @@ export default async function handler(body: Record<string, string>) {
100101
},
101102
emailVerified: new Date(Date.now()),
102103
identityProvider: IdentityProvider.CAL,
104+
organizationId,
103105
},
104106
create: {
105107
username: correctedUsername,
106108
email: userEmail,
107109
password: { create: { hash: hashedPassword } },
108110
identityProvider: IdentityProvider.CAL,
111+
organizationId,
109112
},
110113
});
111114

0 commit comments

Comments
 (0)