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 <udit.07814802719@cse.mait.ac.in>

* fix: use upsert

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>

* Update apps/web/pages/api/auth/signup.ts

Co-authored-by: Leo Giovanetti <hello@leog.me>

---------

Signed-off-by: Udit Takkar <udit.07814802719@cse.mait.ac.in>
Co-authored-by: Leo Giovanetti <hello@leog.me>
test/msw-gcal
Udit Takkar 2023-09-21 06:32:10 +05:30 committed by GitHub
parent 3a3d8db489
commit 96263b0cf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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: {