feat(server): Per user asset access control (#993)

* Limit asset access to owner

* Check public albums for asset

* Clean up

* Fix test

* Rename repository method

* Simplify control flow

* Revert "Simplify control flow"

This reverts commit 7bc3cbf687.

* Revert Makefile change
This commit is contained in:
Matthias Rupp
2022-12-04 18:42:36 +01:00
committed by GitHub
parent 5f2b75997f
commit e8bbad6772
8 changed files with 84 additions and 16 deletions
@@ -43,6 +43,7 @@ export interface IAssetRepository {
userId: string,
checkDuplicateAssetDto: CheckExistingAssetsDto,
): Promise<CheckExistingAssetsResponseDto>;
countByIdAndUser(assetId: string, userId: string): Promise<number>;
}
export const ASSET_REPOSITORY = 'ASSET_REPOSITORY';
@@ -343,4 +344,13 @@ export class AssetRepository implements IAssetRepository {
});
return new CheckExistingAssetsResponseDto(existingAssets.map((a) => a.deviceAssetId));
}
async countByIdAndUser(assetId: string, userId: string): Promise<number> {
return await this.assetRepository.count({
where: {
id: assetId,
userId
}
});
}
}