From 74da15e20d353e9c0cc0221a791962454f6abf90 Mon Sep 17 00:00:00 2001 From: Sergey Kondrikov Date: Tue, 15 Aug 2023 19:02:38 +0300 Subject: [PATCH] fix(web,server): disable partner's archive access (#3695) --- server/src/domain/access/access.core.ts | 5 +++++ server/src/domain/asset/asset.service.ts | 3 +++ web/src/routes/(user)/partners/[userId]/+page.svelte | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/domain/access/access.core.ts b/server/src/domain/access/access.core.ts index d81561236..3e3d4a469 100644 --- a/server/src/domain/access/access.core.ts +++ b/server/src/domain/access/access.core.ts @@ -19,6 +19,8 @@ export enum Permission { ALBUM_SHARE = 'album.share', ALBUM_DOWNLOAD = 'album.download', + ARCHIVE_READ = 'archive.read', + LIBRARY_READ = 'library.read', LIBRARY_DOWNLOAD = 'library.download', } @@ -156,6 +158,9 @@ export class AccessCore { case Permission.ALBUM_REMOVE_ASSET: return this.repository.album.hasOwnerAccess(authUser.id, id); + case Permission.ARCHIVE_READ: + return authUser.id === id; + case Permission.LIBRARY_READ: return authUser.id === id || (await this.repository.library.hasPartnerAccess(authUser.id, id)); diff --git a/server/src/domain/asset/asset.service.ts b/server/src/domain/asset/asset.service.ts index ac655b807..2d4051b0f 100644 --- a/server/src/domain/asset/asset.service.ts +++ b/server/src/domain/asset/asset.service.ts @@ -148,6 +148,9 @@ export class AssetService { if (dto.albumId) { await this.access.requirePermission(authUser, Permission.ALBUM_READ, [dto.albumId]); } else if (dto.userId) { + if (dto.isArchived !== false) { + await this.access.requirePermission(authUser, Permission.ARCHIVE_READ, [dto.userId]); + } await this.access.requirePermission(authUser, Permission.LIBRARY_READ, [dto.userId]); } else { dto.userId = authUser.id; diff --git a/web/src/routes/(user)/partners/[userId]/+page.svelte b/web/src/routes/(user)/partners/[userId]/+page.svelte index c7fd51f2a..adc718e91 100644 --- a/web/src/routes/(user)/partners/[userId]/+page.svelte +++ b/web/src/routes/(user)/partners/[userId]/+page.svelte @@ -18,7 +18,7 @@ export let data: PageData; - const assetStore = new AssetStore({ size: TimeBucketSize.Month, userId: data.partner.id }); + const assetStore = new AssetStore({ size: TimeBucketSize.Month, userId: data.partner.id, isArchived: false }); const assetInteractionStore = createAssetInteractionStore(); const { isMultiSelectState, selectedAssets } = assetInteractionStore;