Compare commits

..
4 changed files with 8 additions and 26 deletions
-3
View File
@@ -1321,9 +1321,6 @@
"Users" "Users"
], ],
"security": [ "security": [
{
"access-token": []
},
{ {
"access-token": [] "access-token": []
} }
@@ -630,39 +630,21 @@ export class PlatformApiController {
@ApiOperation({ summary: 'Execute a pipeline' }) @ApiOperation({ summary: 'Execute a pipeline' })
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE) @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
async executePipeline(@Body() body: any, @User() user: RequestUser) { async executePipeline(@Body() body: any, @User() user: RequestUser) {
// Inject customer_id (actually customer_name) into body for Platform-API return this.platformApiService.proxy('POST', '/pipeline/execute', user, body);
// Note: Platform-API was created before customer_id existed, so it expects customer_name in the customer_id field
const enrichedBody = {
...body,
customer_id: user.customer_name,
};
return this.platformApiService.proxy('POST', '/pipeline/execute', user, enrichedBody);
} }
@Post('pipeline/pause') @Post('pipeline/pause')
@ApiOperation({ summary: 'Pause a pipeline' }) @ApiOperation({ summary: 'Pause a pipeline' })
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE) @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
async pausePipeline(@Body() body: any, @User() user: RequestUser) { async pausePipeline(@Body() body: any, @User() user: RequestUser) {
// Inject customer_id (actually customer_name) into body for Platform-API return this.platformApiService.proxy('POST', '/pipeline/pause', user, body);
// Note: Platform-API was created before customer_id existed, so it expects customer_name in the customer_id field
const enrichedBody = {
...body,
customer_id: user.customer_name,
};
return this.platformApiService.proxy('POST', '/pipeline/pause', user, enrichedBody);
} }
@Post('pipeline/unpause') @Post('pipeline/unpause')
@ApiOperation({ summary: 'Unpause a pipeline' }) @ApiOperation({ summary: 'Unpause a pipeline' })
@RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE) @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.UPDATE)
async unpausePipeline(@Body() body: any, @User() user: RequestUser) { async unpausePipeline(@Body() body: any, @User() user: RequestUser) {
// Inject customer_id (actually customer_name) into body for Platform-API return this.platformApiService.proxy('POST', '/pipeline/unpause', user, body);
// Note: Platform-API was created before customer_id existed, so it expects customer_name in the customer_id field
const enrichedBody = {
...body,
customer_id: user.customer_name,
};
return this.platformApiService.proxy('POST', '/pipeline/unpause', user, enrichedBody);
} }
@Put('pipeline/:pipelineId/memory') @Put('pipeline/:pipelineId/memory')
+4 -1
View File
@@ -266,7 +266,6 @@ export class UsersController {
} }
@Patch(':id') @Patch(':id')
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
@ApiOkResponse({ type: UpdateUserRes }) @ApiOkResponse({ type: UpdateUserRes })
async updateUser( async updateUser(
@User() user: RequestUser, @User() user: RequestUser,
@@ -274,6 +273,10 @@ export class UsersController {
@Param('id') id: string, @Param('id') id: string,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
) { ) {
if (user.user_id !== id || !user.permissions.includes(PERMISSIONS_GROUPS.USERS.permissions.ADMIN.seqid)) {
throw new ErrorBuilder(ErrorCodes.AUTH.FORBIDDEN);
}
this.logger.info('updateUser', { user }); this.logger.info('updateUser', { user });
this.userService.setLanguage(language); this.userService.setLanguage(language);
return await this.userService.updateUser(body, id, user.customer_id); return await this.userService.updateUser(body, id, user.customer_id);
+1 -1
View File
@@ -149,7 +149,7 @@ export class UsersService implements OnModuleInit {
async updateUser(req: UpdateUserReq, id: string, customerId: string) { async updateUser(req: UpdateUserReq, id: string, customerId: string) {
const { roleNames, ...updateUserDTO } = req; const { roleNames, ...updateUserDTO } = req;
if (roleNames) { if (roleNames && roleNames.length > 0) {
await this.setRoles({ roleNames, userId: id }, customerId); await this.setRoles({ roleNames, userId: id }, customerId);
} }