Refactor space permission service

This commit is contained in:
faris Aljohari
2024-05-08 09:35:42 +03:00
parent aff52be540
commit 616ddd4d4c
2 changed files with 21 additions and 17 deletions

View File

@ -11,6 +11,7 @@ export class SpacePermissionService {
userUuid: string,
type: string,
): Promise<void> {
try {
const spaceData = await this.spaceRepository.findOne({
where: {
uuid: spaceUuid,
@ -31,5 +32,8 @@ export class SpacePermissionService {
`You do not have permission to access this ${type}`,
);
}
} catch (err) {
throw new BadRequestException(err.message || 'Invalid UUID');
}
}
}

View File

@ -111,7 +111,7 @@ export class CommunityController {
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@UseGuards(JwtAuthGuard, CommunityPermissionGuard)
@Put('rename/:communityUuid')
async renameCommunityByUuid(
@Param('communityUuid') communityUuid: string,