Compare commits

...
4 Commits
Author SHA1 Message Date
Gabriel Amorim 3d39affc61 Merge pull request #139 from dadosfera/fix/network-config-permissions
FIX: remove permission to delete VPNS
2022-09-16 11:55:50 -03:00
Gabriel Rosa 5d045b675c FIX: remove permission to delete VPNS 2022-09-15 09:48:37 -03:00
Gabriel Amorim bb61990f6e Merge pull request #138 from dadosfera/fix/permission-delete-connection
FIX: remove permission to delete connection
2022-09-15 08:50:41 -03:00
Gabriel Rosa 80442c509a FIX: remove permission to delete connection 2022-09-15 08:33:47 -03:00
4 changed files with 78 additions and 72 deletions
+21 -20
View File
@@ -125,16 +125,17 @@ export const PERMISSIONS_GROUPS = {
'es-es': 'Crear Source',
},
},
DELETE: {
seqid: 38,
claim: 'connection:delete',
usage: PermissionUsages.PUBLIC,
name: {
'pt-br': 'Excluir Fonte',
'en-us': 'Remove Source',
'es-s': 'Eliminar 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',
// },
// },
UPDATE: {
seqid: 39,
claim: 'connection:update',
@@ -165,16 +166,16 @@ export const PERMISSIONS_GROUPS = {
'es-es': 'Crear VPN',
},
},
DELETE: {
seqid: 36,
claim: 'network_config:delete',
usage: PermissionUsages.PUBLIC,
name: {
'pt-br': 'Excluir VPN',
'en-us': 'Remove VPN',
'es-es': 'Eliminar VPN',
},
},
// DELETE: {
// seqid: 36,
// claim: 'network_config:delete',
// usage: PermissionUsages.PUBLIC,
// name: {
// 'pt-br': 'Excluir VPN',
// 'en-us': 'Remove VPN',
// 'es-es': 'Eliminar VPN',
// },
// },
},
},
+20 -20
View File
@@ -103,29 +103,29 @@ export class ConnectionController {
return response;
}
@Delete('/:id')
@RequireAllPermissions(connectionPermissions.DELETE)
async deleteConnection(
@User() user: RequestUser,
@Param('id') id: string,
): Promise<ConnectionRes> {
this.logger.info('/connections - Delete Connection');
// @Delete('/:id')
// @RequireAllPermissions(connectionPermissions.DELETE)
// async deleteConnection(
// @User() user: RequestUser,
// @Param('id') id: string,
// ): Promise<ConnectionRes> {
// 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(
@@ -25,7 +25,10 @@ import {
UpdateNetworkConfigRes,
} from './dto/network-config';
import { FileInterceptor } from '@nestjs/platform-express';
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
import { RequireAllPermissions } from 'src/authentication/authentication.decorator';
const networkConfigPermissions = PERMISSIONS_GROUPS.NETWORK_CONFIG.permissions;
@ApiTags('Network Config')
@Controller('network-config')
export class NetworkConfigController {
@@ -92,6 +95,7 @@ export class NetworkConfigController {
@Post()
@ApiOkResponse({ type: CreateNetworkConfigRes })
@RequireAllPermissions(networkConfigPermissions.CREATE)
@ApiConsumes('multipart/form-data')
@UseInterceptors(FileInterceptor('ovpn_file'))
async createNetworkConfigs(
@@ -111,36 +115,37 @@ export class NetworkConfigController {
});
}
@Patch(':id')
@ApiOkResponse({ type: UpdateNetworkConfigRes })
async updateNetworkConfig(
@User() user: RequestUser,
@Param('id') network_config_id: string,
@Body() body: UpdateNetworkConfigReq,
) {
this.logger.info('PATCH /network-config/:id', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.updateNetworkConfig(
body,
network_config_id,
);
}
// @Patch(':id')
// @ApiOkResponse({ type: UpdateNetworkConfigRes })
// @RequireAllPermissions(networkConfigPermissions.CREATE)
// async updateNetworkConfig(
// @User() user: RequestUser,
// @Param('id') network_config_id: string,
// @Body() body: UpdateNetworkConfigReq,
// ) {
// this.logger.info('PATCH /network-config/:id', {
// user: user.user_id,
// customer: user.customer_name,
// });
// return this.networkConfigService.updateNetworkConfig(
// body,
// network_config_id,
// );
// }
@Delete(':id')
@ApiOkResponse({ type: DeleteNetworkConfigRes })
async deleteNetworkConfig(
@User() user: RequestUser,
@Param('id') network_config_id: string,
) {
this.logger.info('DELETE /network-config', {
user: user.user_id,
customer: user.customer_name,
});
return this.networkConfigService.deleteNetworkConfig(network_config_id, {
customer_name: user.customer_name,
customer_id: user.customer_id,
});
}
// @Delete(':id')
// @ApiOkResponse({ type: DeleteNetworkConfigRes })
// async deleteNetworkConfig(
// @User() user: RequestUser,
// @Param('id') network_config_id: string,
// ) {
// this.logger.info('DELETE /network-config', {
// user: user.user_id,
// customer: user.customer_name,
// });
// return this.networkConfigService.deleteNetworkConfig(network_config_id, {
// customer_name: user.customer_name,
// customer_id: user.customer_id,
// });
// }
}
+1 -1
View File
File diff suppressed because one or more lines are too long