From beb27a0f60fa3404273af201e001f2f521597782 Mon Sep 17 00:00:00 2001 From: Victor Radael Date: Mon, 3 Oct 2022 16:52:42 -0300 Subject: [PATCH 1/3] FIX: unkown error get user by id --- src/modules/catalog/catalog.service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/catalog/catalog.service.ts b/src/modules/catalog/catalog.service.ts index 59e5dc1..8c793d8 100644 --- a/src/modules/catalog/catalog.service.ts +++ b/src/modules/catalog/catalog.service.ts @@ -110,7 +110,7 @@ class CatalogService implements OnModuleInit { } async getUserRolesIds(userId: string) { - const result = await this.userService.findOneById(userId); + const result = await this.userService.findOneById(userId).catch(() => null); const roles_ids = result.user.roles.map((role) => role.id); @@ -139,7 +139,7 @@ class CatalogService implements OnModuleInit { const condition = asset.owner && !asset.owner.includes('@') ? true : false; const result = condition - ? await this.userService.findOneById(asset.owner) + ? await this.userService.findOneById(asset.owner).catch(() => null) : null; const owner = result !== null ? result.user.username : null; @@ -151,7 +151,7 @@ class CatalogService implements OnModuleInit { const condition = asset.owner && !asset.owner.includes('@') ? true : false; const result = condition - ? await this.userService.findOneById(asset.owner) + ? await this.userService.findOneById(asset.owner).catch(() => null) : null; const owner = result !== null ? result.user.username : null; @@ -177,7 +177,9 @@ class CatalogService implements OnModuleInit { const opensearchTable = JSON.parse(data_asset); const result = opensearchTable.user_id - ? await this.userService.findOneById(opensearchTable.owner) + ? await this.userService + .findOneById(opensearchTable.owner) + .catch(() => null) : null; const owner = result !== null ? result.user.username : null; @@ -213,7 +215,9 @@ class CatalogService implements OnModuleInit { ); const opensearchTable = JSON.parse(data_asset); const result = opensearchTable.user_id - ? await this.userService.findOneById(opensearchTable.owner) + ? await this.userService + .findOneById(opensearchTable.owner) + .catch(() => null) : null; const owner = result !== null ? result.user.username : null; From 28280dca8df501d496509f5ea345017b86d8bd58 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Tue, 4 Oct 2022 14:46:52 -0300 Subject: [PATCH 2/3] FIX: Delete connections permission --- src/authentication/permissions.enum.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/authentication/permissions.enum.ts b/src/authentication/permissions.enum.ts index cc53a2b..edcc90f 100644 --- a/src/authentication/permissions.enum.ts +++ b/src/authentication/permissions.enum.ts @@ -125,17 +125,16 @@ export const PERMISSIONS_GROUPS = { 'es-es': 'Crear Source', }, }, - //TODO descomentar quando tiver ok o DELETE de conexões - // DELETE: { - // seqid: 38, - // claim: 'connection:delete', - // usage: PermissionUsages.PUBLIC, - // name: { - // 'pt-br': 'Excluir Fonte', - // 'en-us': 'Remove Source', - // 'es-s': 'Eliminar Source', - // }, - // }, + DELETE: { + seqid: 38, + claim: 'connection:delete', + usage: PermissionUsages.INTERNAL, + name: { + 'pt-br': 'Excluir Fonte', + 'en-us': 'Remove Source', + 'es-s': 'Eliminar Source', + }, + }, UPDATE: { seqid: 39, claim: 'connection:update', From b311a84bde838ef5b20052a809a52ef039d24b41 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Tue, 4 Oct 2022 15:22:43 -0300 Subject: [PATCH 3/3] FIX: delete route reimplemented --- .../connection/connection.controller.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/modules/connection/connection.controller.ts b/src/modules/connection/connection.controller.ts index a86904c..1d614bd 100644 --- a/src/modules/connection/connection.controller.ts +++ b/src/modules/connection/connection.controller.ts @@ -105,29 +105,29 @@ export class ConnectionController { return response; } - // @Delete('/:id') - // @RequireAllPermissions(connectionPermissions.DELETE) - // async deleteConnection( - // @User() user: RequestUser, - // @Param('id') id: string, - // ): Promise { - // this.logger.info('/connections - Delete Connection'); + @Delete('/:id') + @RequireAllPermissions(connectionPermissions.DELETE) + async deleteConnection( + @User() user: RequestUser, + @Param('id') id: string, + ): Promise { + this.logger.info('/connections - Delete Connection'); - // const { user_id, customer_id, customer_name, username } = user; - // const metadata = PackTheMetadata({ - // user_id, - // customer_id, - // customer_name, - // username, - // }); + const { user_id, customer_id, customer_name, username } = user; + const metadata = PackTheMetadata({ + user_id, + customer_id, + customer_name, + username, + }); - // const response: any = await this.clientService.deleteConnection({ - // body: { id }, - // metadata, - // }); + const response: any = await this.clientService.deleteConnection({ + body: { id }, + metadata, + }); - // return response; - // } + return response; + } @Get() async getAllConnections(