Skip to content

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

misc: add custom role slug in fetch group

Sheen Capadngan06a7e804ebfd
diff --git a/backend/src/ee/routes/v1/group-router.ts b/backend/src/ee/routes/v1/group-router.ts
index d10e1800b4..ec235d34eb 100644
--- a/backend/src/ee/routes/v1/group-router.ts
+++ b/backend/src/ee/routes/v1/group-router.ts
@@ -48,7 +48,9 @@ export const registerGroupRouter = async (server: FastifyZodProvider) => {
id: z.string().trim().describe(GROUPS.GET_BY_ID.id)
}),
response: {
- 200: GroupsSchema
+ 200: GroupsSchema.extend({
+ customRoleSlug: z.string().nullable()
+ })
}
},
handler: async (req) => {
diff --git a/backend/src/ee/services/group/group-dal.ts b/backend/src/ee/services/group/group-dal.ts
index 801f52fc0a..708fbdbd36 100644
--- a/backend/src/ee/services/group/group-dal.ts
+++ b/backend/src/ee/services/group/group-dal.ts
@@ -169,11 +169,29 @@ export const groupDALFactory = (db: TDbClient) => {
}
};
+ const findById = async (id: string, tx?: Knex) => {
+ try {
+ const doc = await (tx || db.replicaNode())(TableName.Groups)
+ .leftJoin(TableName.OrgRoles, `${TableName.Groups}.roleId`, `${TableName.OrgRoles}.id`)
+ .where(`${TableName.Groups}.id`, id)
+ .select(
+ selectAllTableCols(TableName.Groups),
+ db.ref("slug").as("customRoleSlug").withSchema(TableName.OrgRoles)
+ )
+ .first();
+
+ return doc;
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Find by id" });
+ }
+ };
+
return {
+ ...groupOrm,
findGroups,
findByOrgId,
findAllGroupPossibleMembers,
findGroupsByProjectId,
- ...groupOrm
+ findById
};
};