Skip to content

Commit 1309f6c

Browse files
committed
feat: enhance role filtering in RolesController and update useAgentsSchema
- Added support for excluding internal roles in the RolesController by introducing a new query parameter `excludeInternal`. - Updated the useAgentsSchema to include the `excludeInternal` parameter in the request configuration, improving role management and access control capabilities.
1 parent 9a69e71 commit 1309f6c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

apps/api/src/core/roles/roles.controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Types } from "mongoose"
1414
import { ApiUpdateDecorator } from "~/_common/decorators/api-update.decorator"
1515
import { ApiDeletedResponseDecorator } from "~/_common/decorators/api-deleted-response.decorator"
1616
import { UseRoles } from "~/_common/decorators/use-roles.decorator"
17-
import { AC_ACTIONS, AC_ALL_DEFAULT_ROLES, AC_DEFAULT_POSSESSION, AC_GUEST_ROLE } from "~/_common/types/ac-types"
17+
import { AC_ACTIONS, AC_ALL_DEFAULT_ROLES, AC_DEFAULT_POSSESSION, AC_GUEST_ROLE, AC_INTERNAL_ROLE_PREFIX } from "~/_common/types/ac-types"
1818
import { Roles } from "./_schemas/roles.schema"
1919
import { AclRuntimeService } from "./acl-runtime.service"
2020

@@ -49,14 +49,17 @@ export class RolesController extends AbstractController {
4949
@Res() res: Response,
5050
@Query('excludeAdmin') excludeAdmin: string,
5151
@Query('excludeGuest') excludeGuest: string,
52+
@Query('excludeInternal') excludeInternal: string,
5253
): Promise<Response> {
5354
const data = await this._service.find(null, { name: 1, displayName: 1, description: 1 }) as unknown as Roles[]
5455

5556
const shouldExcludeAdmin = `${excludeAdmin ?? ''}`.toLowerCase() === 'true'
5657
const shouldExcludeGuest = `${excludeGuest ?? ''}`.toLowerCase() === 'true'
58+
const shouldExcludeInternal = `${excludeInternal ?? ''}`.toLowerCase() === 'true'
5759
const filter = (r: { name: string }) =>
5860
(!shouldExcludeAdmin || r.name !== 'admin')
5961
&& (!shouldExcludeGuest || r.name !== 'guest')
62+
&& (!shouldExcludeInternal || !r.name.startsWith(AC_INTERNAL_ROLE_PREFIX))
6063

6164
return res.status(HttpStatus.OK).json({
6265
statusCode: HttpStatus.OK,

apps/web/src/composables/useAgentsSchema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ export default function useAgentsSchema() {
123123
itemsPath: 'data',
124124
labelKey: 'displayName',
125125
valueKey: 'name',
126+
params: {
127+
excludeInternal: 'true',
128+
},
126129
headers: {
127130
accept: 'application/json',
128131
},

0 commit comments

Comments
 (0)