From 96263b0cf75e7b7db7bf03c4c6a81a3e7c72068f Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Thu, 21 Sep 2023 06:32:10 +0530 Subject: [PATCH] fix: team members not showing up in org members list (#11456) * fix: team members not showing up in org members list Signed-off-by: Udit Takkar * fix: use upsert Signed-off-by: Udit Takkar * Update apps/web/pages/api/auth/signup.ts Co-authored-by: Leo Giovanetti --------- Signed-off-by: Udit Takkar Co-authored-by: Leo Giovanetti --- apps/web/pages/api/auth/signup.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/web/pages/api/auth/signup.ts b/apps/web/pages/api/auth/signup.ts index 4004aa5418569d..24d9de40fe2b44 100644 --- a/apps/web/pages/api/auth/signup.ts +++ b/apps/web/pages/api/auth/signup.ts @@ -130,6 +130,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) // Accept any child team invites for orgs and create a membership for the org itself if (team.parentId) { + // Create (when invite link is used) or Update (when regular email invitation is used) membership for the organization itself + await prisma.membership.upsert({ + where: { + userId_teamId: { userId: user.id, teamId: team.parentId }, + }, + update: { + accepted: true, + }, + create: { + userId: user.id, + teamId: team.parentId, + accepted: true, + role: MembershipRole.MEMBER, + }, + }); + // We do a membership update twice so we can join the ORG invite if the user is invited to a team witin a ORG await prisma.membership.updateMany({ where: {