mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-13 00:02:30 +10:00
validate
This commit is contained in:
@ -156,6 +156,9 @@ export class PageController {
|
|||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
) {
|
) {
|
||||||
const history = await this.pageHistoryService.findById(dto.historyId);
|
const history = await this.pageHistoryService.findById(dto.historyId);
|
||||||
|
if (!history) {
|
||||||
|
throw new NotFoundException('Page history not found');
|
||||||
|
}
|
||||||
|
|
||||||
const ability = await this.spaceAbility.createForUser(
|
const ability = await this.spaceAbility.createForUser(
|
||||||
user,
|
user,
|
||||||
@ -175,7 +178,6 @@ export class PageController {
|
|||||||
@AuthUser() user: User,
|
@AuthUser() user: User,
|
||||||
) {
|
) {
|
||||||
const ability = await this.spaceAbility.createForUser(user, dto.spaceId);
|
const ability = await this.spaceAbility.createForUser(user, dto.spaceId);
|
||||||
console.log(ability.can(SpaceCaslAction.Read, SpaceCaslSubject.Page));
|
|
||||||
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
if (ability.cannot(SpaceCaslAction.Read, SpaceCaslSubject.Page)) {
|
||||||
throw new ForbiddenException();
|
throw new ForbiddenException();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user