fix: saml does not add future members to eventtype (#17522)
* fix: trigger createOrUpdateMemberships from dsync so SAML signup triggers side-effects * forEach does not wait for async/await done-ness
This commit is contained in:
@@ -12,7 +12,7 @@ export const createOrUpdateMemberships = async ({
|
||||
}: {
|
||||
user: Pick<User, "id">;
|
||||
team: Pick<Team, "id" | "parentId" | "isOrganization"> & {
|
||||
organizationSettings: OrganizationSettings | null;
|
||||
organizationSettings?: Pick<OrganizationSettings, "orgAutoAcceptEmail"> | null;
|
||||
};
|
||||
}) => {
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ProfileRepository } from "@calcom/lib/server/repository/profile";
|
||||
import { createOrUpdateMemberships } from "@calcom/features/auth/signup/utils/createOrUpdateMemberships";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import prisma from "@calcom/prisma";
|
||||
import type { IdentityProvider } from "@calcom/prisma/enums";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
|
||||
import dSyncUserSelect from "./dSyncUserSelect";
|
||||
|
||||
@@ -50,26 +49,17 @@ const createUsersAndConnectToOrg = async (
|
||||
},
|
||||
select: dSyncUserSelect,
|
||||
});
|
||||
|
||||
await prisma.membership.createMany({
|
||||
data: users.map((user) => ({
|
||||
accepted: true,
|
||||
userId: user.id,
|
||||
teamId: organizationId,
|
||||
role: MembershipRole.MEMBER,
|
||||
})),
|
||||
});
|
||||
|
||||
await prisma.profile.createMany({
|
||||
data: users.map((user) => ({
|
||||
uid: ProfileRepository.generateProfileUid(),
|
||||
userId: user.id,
|
||||
// The username is already set when creating the user
|
||||
username: user.username!,
|
||||
organizationId,
|
||||
})),
|
||||
});
|
||||
|
||||
// Assign created users to organization
|
||||
for (const user of users) {
|
||||
await createOrUpdateMemberships({
|
||||
user,
|
||||
team: {
|
||||
id: organizationId,
|
||||
isOrganization: true,
|
||||
parentId: null, // orgs don't have a parentId
|
||||
},
|
||||
});
|
||||
}
|
||||
return users;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user