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:
@@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user