mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
Refactor space permission service
This commit is contained in:
@ -11,25 +11,29 @@ export class SpacePermissionService {
|
||||
userUuid: string,
|
||||
type: string,
|
||||
): Promise<void> {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: {
|
||||
uuid: spaceUuid,
|
||||
spaceType: {
|
||||
type: type,
|
||||
},
|
||||
userSpaces: {
|
||||
user: {
|
||||
uuid: userUuid,
|
||||
try {
|
||||
const spaceData = await this.spaceRepository.findOne({
|
||||
where: {
|
||||
uuid: spaceUuid,
|
||||
spaceType: {
|
||||
type: type,
|
||||
},
|
||||
userSpaces: {
|
||||
user: {
|
||||
uuid: userUuid,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
relations: ['spaceType', 'userSpaces', 'userSpaces.user'],
|
||||
});
|
||||
relations: ['spaceType', 'userSpaces', 'userSpaces.user'],
|
||||
});
|
||||
|
||||
if (!spaceData) {
|
||||
throw new BadRequestException(
|
||||
`You do not have permission to access this ${type}`,
|
||||
);
|
||||
if (!spaceData) {
|
||||
throw new BadRequestException(
|
||||
`You do not have permission to access this ${type}`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
throw new BadRequestException(err.message || 'Invalid UUID');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ export class CommunityController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseGuards(JwtAuthGuard, CommunityPermissionGuard)
|
||||
@Put('rename/:communityUuid')
|
||||
async renameCommunityByUuid(
|
||||
@Param('communityUuid') communityUuid: string,
|
||||
|
Reference in New Issue
Block a user