fix: only check for delete protection if deleting org identity, not sub-org identity membership

This commit is contained in:
Scott Wilson
2025-11-06 16:45:05 -08:00
committed by =
parent 3c79ffb16c
commit d026de4ec1

View File

@@ -329,14 +329,14 @@ export const identityServiceFactory = ({
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);
if (identityOrgMembership.identity.hasDeleteProtection)
throw new BadRequestError({ message: "Identity has delete protection" });
if (identityOrgMembership.identity.projectId) {
throw new BadRequestError({ message: `Identity is managed by project` });
}
if (identityOrgMembership.identity.orgId === actorOrgId) {
if (identityOrgMembership.identity.hasDeleteProtection)
throw new BadRequestError({ message: "Identity has delete protection" });
const deletedIdentity = await identityDAL.deleteById(id);
await licenseService.updateSubscriptionOrgMemberCount(identityOrgMembership.scopeOrgId);
return { ...deletedIdentity, orgId: identityOrgMembership.scopeOrgId };