mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
soft deleted page checks
This commit is contained in:
@@ -54,7 +54,7 @@ export class AuthenticationExtension implements Extension {
|
||||
|
||||
const page = await this.pageRepo.findById(pageId);
|
||||
if (!page) {
|
||||
this.logger.warn(`Page not found: ${pageId}`);
|
||||
this.logger.debug(`Page not found: ${pageId}`);
|
||||
throw new NotFoundException('Page not found');
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ export class AuthenticationExtension implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if (page.deletedAt) {
|
||||
data.connectionConfig.readOnly = true;
|
||||
}
|
||||
|
||||
this.logger.debug(`Authenticated user ${user.id} on page ${pageId}`);
|
||||
|
||||
return {
|
||||
|
||||
@@ -80,7 +80,11 @@ export class PageController {
|
||||
const parentPage = await this.pageRepo.findById(
|
||||
createPageDto.parentPageId,
|
||||
);
|
||||
if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) {
|
||||
if (
|
||||
!parentPage ||
|
||||
parentPage.deletedAt ||
|
||||
parentPage.spaceId !== createPageDto.spaceId
|
||||
) {
|
||||
throw new NotFoundException('Parent page not found');
|
||||
}
|
||||
await this.pageAccessService.validateCanEdit(parentPage, user);
|
||||
@@ -411,9 +415,10 @@ export class PageController {
|
||||
// If moving to a new parent, check permission on the target parent
|
||||
if (dto.parentPageId && dto.parentPageId !== movedPage.parentPageId) {
|
||||
const targetParent = await this.pageRepo.findById(dto.parentPageId);
|
||||
if (targetParent) {
|
||||
await this.pageAccessService.validateCanEdit(targetParent, user);
|
||||
if (!targetParent || targetParent.deletedAt) {
|
||||
throw new NotFoundException('Target parent page not found');
|
||||
}
|
||||
await this.pageAccessService.validateCanEdit(targetParent, user);
|
||||
}
|
||||
|
||||
return this.pageService.movePage(dto, movedPage);
|
||||
|
||||
@@ -83,7 +83,11 @@ export class PageService {
|
||||
createPageDto.parentPageId,
|
||||
);
|
||||
|
||||
if (!parentPage || parentPage.spaceId !== createPageDto.spaceId) {
|
||||
if (
|
||||
!parentPage ||
|
||||
parentPage.deletedAt ||
|
||||
parentPage.spaceId !== createPageDto.spaceId
|
||||
) {
|
||||
throw new NotFoundException('Parent page not found');
|
||||
}
|
||||
|
||||
@@ -600,7 +604,11 @@ export class PageService {
|
||||
// changing the page's parent
|
||||
if (dto.parentPageId) {
|
||||
const parentPage = await this.pageRepo.findById(dto.parentPageId);
|
||||
if (!parentPage || parentPage.spaceId !== movedPage.spaceId) {
|
||||
if (
|
||||
!parentPage ||
|
||||
parentPage.deletedAt ||
|
||||
parentPage.spaceId !== movedPage.spaceId
|
||||
) {
|
||||
throw new NotFoundException('Parent page not found');
|
||||
}
|
||||
parentPageId = parentPage.id;
|
||||
|
||||
Reference in New Issue
Block a user