Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: review changes

Piyush Guptad41ece8a26b6
diff --git a/backend/src/ee/services/group/group-dal.ts b/backend/src/ee/services/group/group-dal.ts
index 7638b0f128..df4e1b5dde 100644
--- a/backend/src/ee/services/group/group-dal.ts
+++ b/backend/src/ee/services/group/group-dal.ts
@@ -237,10 +237,10 @@ export const groupDALFactory = (db: TDbClient) => {
const identities = await query;
return {
- identities: identities.map(({ name, identityId, joinedGroupAt }) => ({
+ identities: identities.map(({ name, identityId, joinedGroupAt, groupId: identityGroupId }) => ({
id: identityId,
name,
- isPartOfGroup: !!groupId,
+ isPartOfGroup: !!identityGroupId,
joinedGroupAt
})),
// @ts-expect-error col select is raw and not strongly typed
diff --git a/backend/src/ee/services/group/group-fns.ts b/backend/src/ee/services/group/group-fns.ts
index 15f76ac093..a775794693 100644
--- a/backend/src/ee/services/group/group-fns.ts
+++ b/backend/src/ee/services/group/group-fns.ts
@@ -303,7 +303,7 @@ export const addIdentitiesToGroup = async ({
const identityIdsSet = new Set(identityIds);
const identityIdsArray = Array.from(identityIdsSet);
- const foundIdentities = await identityOrgMembershipDAL.findByIds(identityIdsArray, tx);
+ const foundIdentities = await identityOrgMembershipDAL.findByIds(identityIdsArray, group.orgId, tx);
const existingIdentityOrgMembershipsIdentityIdsSet = new Set(foundIdentities.map((u) => u.id));
@@ -500,7 +500,7 @@ export const removeIdentitiesFromGroup = async ({
const identityIdsSet = new Set(identityIds);
const identityIdsArray = Array.from(identityIdsSet);
- const foundIdentities = await identityOrgMembershipDAL.findByIds(identityIdsArray, tx);
+ const foundIdentities = await identityOrgMembershipDAL.findByIds(identityIdsArray, group.orgId, tx);
if (foundIdentities.length !== identityIdsArray.length) {
throw new NotFoundError({
diff --git a/backend/src/ee/services/group/group-service.ts b/backend/src/ee/services/group/group-service.ts
index 6fc5668e78..060774e77f 100644
--- a/backend/src/ee/services/group/group-service.ts
+++ b/backend/src/ee/services/group/group-service.ts
@@ -672,7 +672,7 @@ export const groupServiceFactory = ({
details: { missingPermissions: permissionBoundary.missingPermissions }
});
- const [identity] = await identityOrgMembershipDAL.findByIds([identityId]);
+ const [identity] = await identityOrgMembershipDAL.findByIds([identityId], group.orgId);
if (!identity) {
throw new NotFoundError({ message: `Identity with id ${identityId} is not part of the organization` });
@@ -824,7 +824,7 @@ export const groupServiceFactory = ({
details: { missingPermissions: permissionBoundary.missingPermissions }
});
- const [identity] = await identityOrgMembershipDAL.findByIds([identityId]);
+ const [identity] = await identityOrgMembershipDAL.findByIds([identityId], group.orgId);
if (!identity)
throw new NotFoundError({ message: `Identity with id ${identityId} is not part of the organization` });
diff --git a/backend/src/services/identity/identity-org-dal.ts b/backend/src/services/identity/identity-org-dal.ts
index 7c92dad289..5dac91ad23 100644
--- a/backend/src/services/identity/identity-org-dal.ts
+++ b/backend/src/services/identity/identity-org-dal.ts
@@ -674,11 +674,12 @@ export const identityOrgDALFactory = (db: TDbClient) => {
}
};
- const findByIds = async (identityIds: string[], tx?: Knex) => {
+ const findByIds = async (identityIds: string[], orgId: string, tx?: Knex) => {
try {
const identities = await (tx || db.replicaNode())(TableName.Identity)
.join(TableName.Membership, `${TableName.Membership}.actorIdentityId`, `${TableName.Identity}.id`)
.where(`${TableName.Membership}.scope`, AccessScope.Organization)
+ .where(`${TableName.Membership}.scopeOrgId`, orgId)
.whereNotNull(`${TableName.Membership}.actorIdentityId`)
.whereNull(`${TableName.Identity}.projectId`)
.whereIn(`${TableName.Identity}.id`, identityIds)