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, userUuid: string,
type: string, type: string,
): Promise<void> { ): Promise<void> {
try {
const spaceData = await this.spaceRepository.findOne({ const spaceData = await this.spaceRepository.findOne({
where: { where: {
uuid: spaceUuid, uuid: spaceUuid,
@ -31,5 +32,8 @@ export class SpacePermissionService {
`You do not have permission to access this ${type}`, `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() @ApiBearerAuth()
@UseGuards(JwtAuthGuard) @UseGuards(JwtAuthGuard, CommunityPermissionGuard)
@Put('rename/:communityUuid') @Put('rename/:communityUuid')
async renameCommunityByUuid( async renameCommunityByUuid(
@Param('communityUuid') communityUuid: string, @Param('communityUuid') communityUuid: string,