fix: subteam invite org acceptance (#11449)

This commit is contained in:
Leo Giovanetti
2023-09-19 14:42:37 -07:00
committed by GitHub
parent 37f01db0da
commit 3fdc41968f
3 changed files with 2 additions and 12 deletions
-10
View File
@@ -130,16 +130,6 @@ 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 a membership for the organization itself
await prisma.membership.create({
data: {
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: {
+1 -1
View File
@@ -302,7 +302,7 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
const isOrganization = tokenTeam.metadata?.isOrganization || tokenTeam?.parentId !== null;
// If we are dealing with an org, the slug may come from the team itself or its parent
const orgSlug = isOrganization
? tokenTeam.slug || tokenTeam.metadata?.requestedSlug || tokenTeam.parent?.slug
? tokenTeam.metadata?.requestedSlug || tokenTeam.parent?.slug || tokenTeam.slug
: null;
// Org context shouldn't check if a username is premium
@@ -257,7 +257,7 @@ export async function sendVerificationEmail({
expires: new Date(new Date().setHours(168)), // +1 week
team: {
connect: {
id: connectionInfo.orgId || input.teamId,
id: input.teamId,
},
},
},