Skip to content

Commit

Permalink
[front] Give access to all groups for system key (#9401)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier authored Dec 16, 2024
1 parent 722a6c6 commit 9d95583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
30 changes: 10 additions & 20 deletions front/lib/resources/group_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,16 @@ export class GroupResource extends BaseResource<GroupModel> {
static async listWorkspaceGroupsFromKey(
key: KeyResource
): Promise<GroupResource[]> {
let whereCondition: WhereOptions<GroupModel> = {
workspaceId: key.workspaceId,
};

// If the key is a system key, we also include the global group.
if (key.isSystem) {
whereCondition = {
...whereCondition,
[Op.or]: [
{ kind: { [Op.in]: ["system", "global"] } },
{ id: key.groupId },
],
};
} else {
// If it's not a system key, we only fetch the associated group.
whereCondition = {
...whereCondition,
id: key.groupId,
};
}
const whereCondition: WhereOptions<GroupModel> = key.isSystem
? // If the key is a system key, we include all groups in the workspace.
{
workspaceId: key.workspaceId,
}
: // If it's not a system key, we only fetch the associated group.
{
workspaceId: key.workspaceId,
id: key.groupId,
};

const groups = await this.model.findAll({
where: whereCondition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ async function handler(
if (
!dataSource ||
dataSource.space.sId !== spaceId ||
(!dataSource.canRead(auth) && !auth.isSystemKey())
!dataSource.canRead(auth)
) {
return apiError(req, res, {
status_code: 404,
Expand Down

0 comments on commit 9d95583

Please sign in to comment.