1
- import { Controller , ForbiddenException , Get , NotFoundException , Param , Res } from "@nestjs/common" ;
1
+ import { Controller , ForbiddenException , Get , Inject , NotFoundException , Param , Res } from "@nestjs/common" ;
2
2
import { Response } from "express" ;
3
3
4
4
import { CurrentUserInterface } from "../../auth/current-user/current-user" ;
5
5
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" ;
7
8
import { FoldersService } from "./folders.service" ;
8
9
9
10
@Controller ( "dam/folders" )
10
11
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
+ ) { }
12
16
13
17
@Get ( "/:folderId/zip" )
14
18
async createZip ( @Param ( "folderId" ) folderId : string , @Res ( ) res : Response , @GetCurrentUser ( ) user : CurrentUserInterface ) : Promise < void > {
@@ -17,7 +21,7 @@ export class FoldersController {
17
21
throw new NotFoundException ( "Folder not found" ) ;
18
22
}
19
23
20
- if ( folder . scope !== undefined && ! this . contentScopeService . canAccessScope ( folder . scope , user ) ) {
24
+ if ( folder . scope && ! this . accessControlService . isAllowed ( user , "dam" , folder . scope ) ) {
21
25
throw new ForbiddenException ( "The current user is not allowed to access this scope and download this folder." ) ;
22
26
}
23
27
0 commit comments