Skip to content

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

join roles

Thiago Araujo da Silva77e10add9404
diff --git a/backend/src/services/identity/identity-org-dal.ts b/backend/src/services/identity/identity-org-dal.ts
index 6c5c3880d2..52a33d83eb 100644
--- a/backend/src/services/identity/identity-org-dal.ts
+++ b/backend/src/services/identity/identity-org-dal.ts
@@ -1057,17 +1057,10 @@ export const identityOrgDALFactory = (db: TDbClient) => {
const query = (tx || db.replicaNode())(TableName.Membership)
.join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Membership}.actorIdentityId`)
+ .leftJoin(TableName.MembershipRole, `${TableName.MembershipRole}.membershipId`, `${TableName.Membership}.id`)
+ .leftJoin(TableName.Role, `${TableName.MembershipRole}.customRoleId`, `${TableName.Role}.id`)
.whereNotNull(`${TableName.Membership}.actorIdentityId`);
- // Role filter requires joining MembershipRole + Role; the COUNT(DISTINCT) below
- // collapses the multi-row fan-out back to one row per membership.
- const hasRoleFilter = Boolean(searchFilter?.role);
- if (hasRoleFilter) {
- void query
- .leftJoin(TableName.MembershipRole, `${TableName.MembershipRole}.membershipId`, `${TableName.Membership}.id`)
- .leftJoin(TableName.Role, `${TableName.MembershipRole}.customRoleId`, `${TableName.Role}.id`);
- }
-
const orgScopeBranch = (sub: Knex.QueryBuilder) => {
void sub
.where(`${TableName.Membership}.scope`, AccessScope.Organization)