From e515295edac170244ef0632be443ea2d9da34b45 Mon Sep 17 00:00:00 2001 From: Pratap2018 Date: Mon, 15 Jul 2024 11:37:07 +0530 Subject: [PATCH] delete vault --- src/user-vault/services/user-vault.service.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/user-vault/services/user-vault.service.ts b/src/user-vault/services/user-vault.service.ts index f4905c2..6bf1cf1 100644 --- a/src/user-vault/services/user-vault.service.ts +++ b/src/user-vault/services/user-vault.service.ts @@ -89,15 +89,18 @@ export class UserVaultService { page, limit, ): Promise> { - // const vault = await this.vaultRepository.getVault({ - // id, - // }); + const vault = await this.vaultRepository.getVault({ + id, + }); - // if (vault == undefined || vault == null) { - // throw new HttpException({ - // message: "Vault with given id does not exists", - // }, HttpStatus.NOT_FOUND) - // } + if (vault == undefined || vault == null) { + throw new HttpException( + { + message: 'Vault with given id does not exists', + }, + HttpStatus.NOT_FOUND, + ); + } // const documentVaultId = getHash(id + vault.invoker); // await this.documentRepository.connectDB(documentVaultId); @@ -278,6 +281,14 @@ export class UserVaultService { HttpStatus.NOT_FOUND, ); } + + if (invoker !== vault.invoker) { + Logger.debug( + `Invoker : ${invoker} is not authorized to access document : ${documentId} `, + 'VaultService - Delete', + ); + throw Error( `Invoker : ${invoker} is not authorized to access document : ${documentId} `) + } // const docVaultId = getHash(id + vault.invoker); // await this.documentRepository.connectDB(docVaultId); if (invoker !== vault.invoker) {