mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
fix: resolved duplicate membership in identity
This commit is contained in:
@@ -93,6 +93,16 @@ export const membershipGroupServiceFactory = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const scopeDatabaseFields = factory.getScopeDatabaseFields(dto.scopeData);
|
const scopeDatabaseFields = factory.getScopeDatabaseFields(dto.scopeData);
|
||||||
|
const existingMembership = await membershipGroupDAL.findOne({
|
||||||
|
scope: scopeData.scope,
|
||||||
|
...scopeDatabaseFields,
|
||||||
|
actorGroupId: dto.data.groupId
|
||||||
|
});
|
||||||
|
if (existingMembership)
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Group is already a member"
|
||||||
|
});
|
||||||
|
|
||||||
await factory.onCreateMembershipGroupGuard(dto);
|
await factory.onCreateMembershipGroupGuard(dto);
|
||||||
|
|
||||||
const customInputRoles = data.roles.filter((el) => factory.isCustomRole(el.role));
|
const customInputRoles = data.roles.filter((el) => factory.isCustomRole(el.role));
|
||||||
|
|||||||
@@ -102,6 +102,16 @@ export const membershipIdentityServiceFactory = ({
|
|||||||
throw new NotFoundError({ message: "One or more custom roles not found" });
|
throw new NotFoundError({ message: "One or more custom roles not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const existingMembership = await membershipIdentityDAL.findOne({
|
||||||
|
scope: scopeData.scope,
|
||||||
|
...scopeDatabaseFields,
|
||||||
|
actorIdentityId: dto.data.identityId
|
||||||
|
});
|
||||||
|
if (existingMembership)
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Identity is already a member"
|
||||||
|
});
|
||||||
|
|
||||||
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
const customRolesGroupBySlug = groupBy(customRoles, ({ slug }) => slug);
|
||||||
|
|
||||||
const membership = await membershipIdentityDAL.transaction(async (tx) => {
|
const membership = await membershipIdentityDAL.transaction(async (tx) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user