Skip to content

Commit 2494ca9

Browse files
committed
Replace ContentScopeService with accessControlService
1 parent 2048789 commit 2494ca9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/api/cms-api/src/dam/files/folders.controller.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { Controller, ForbiddenException, Get, NotFoundException, Param, Res } from "@nestjs/common";
1+
import { Controller, ForbiddenException, Get, Inject, NotFoundException, Param, Res } from "@nestjs/common";
22
import { Response } from "express";
33

44
import { CurrentUserInterface } from "../../auth/current-user/current-user";
55
import { GetCurrentUser } from "../../auth/decorators/get-current-user.decorator";
6-
import { ContentScopeService } from "../../content-scope/content-scope.service";
6+
import { ACCESS_CONTROL_SERVICE } from "../../user-permissions/user-permissions.constants";
7+
import { AccessControlServiceInterface } from "../../user-permissions/user-permissions.types";
78
import { FoldersService } from "./folders.service";
89

910
@Controller("dam/folders")
1011
export class FoldersController {
11-
constructor(private readonly foldersService: FoldersService, private readonly contentScopeService: ContentScopeService) {}
12+
constructor(
13+
private readonly foldersService: FoldersService,
14+
@Inject(ACCESS_CONTROL_SERVICE) private accessControlService: AccessControlServiceInterface,
15+
) {}
1216

1317
@Get("/:folderId/zip")
1418
async createZip(@Param("folderId") folderId: string, @Res() res: Response, @GetCurrentUser() user: CurrentUserInterface): Promise<void> {
@@ -17,7 +21,7 @@ export class FoldersController {
1721
throw new NotFoundException("Folder not found");
1822
}
1923

20-
if (folder.scope !== undefined && !this.contentScopeService.canAccessScope(folder.scope, user)) {
24+
if (folder.scope && !this.accessControlService.isAllowed(user, "dam", folder.scope)) {
2125
throw new ForbiddenException("The current user is not allowed to access this scope and download this folder.");
2226
}
2327

0 commit comments

Comments
 (0)