mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-09 23:29:08 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76485f929d | ||
|
|
1f9d0c29ec | ||
|
|
31f8c2c1a6 | ||
|
|
8b93d4e97b | ||
|
|
adeb022818 | ||
|
|
f61c241dde | ||
|
|
e7f410831f |
@@ -1321,9 +1321,6 @@
|
|||||||
"Users"
|
"Users"
|
||||||
],
|
],
|
||||||
"security": [
|
"security": [
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"access-token": []
|
"access-token": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -630,21 +630,39 @@ 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) {
|
||||||
return this.platformApiService.proxy('POST', '/pipeline/execute', user, body);
|
// Inject customer_id (actually customer_name) into body for Platform-API
|
||||||
|
// 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) {
|
||||||
return this.platformApiService.proxy('POST', '/pipeline/pause', user, body);
|
// Inject customer_id (actually customer_name) into body for Platform-API
|
||||||
|
// 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) {
|
||||||
return this.platformApiService.proxy('POST', '/pipeline/unpause', user, body);
|
// Inject customer_id (actually customer_name) into body for Platform-API
|
||||||
|
// 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')
|
||||||
|
|||||||
@@ -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,18 @@ export class UsersController {
|
|||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
@Language() language: LanguageEnum,
|
@Language() language: LanguageEnum,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
const isSameUser = user.user_id === id;
|
||||||
|
const isSuperAdmin = user.permissions.includes(PERMISSIONS_GROUPS.USERS.permissions.ADMIN.seqid)
|
||||||
|
if (!isSameUser && !isSuperAdmin) {
|
||||||
|
throw new ErrorBuilder(ErrorCodes.AUTH.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSameUser && !isSuperAdmin && body.roleNames) {
|
||||||
|
// Prevent users from updating their own roles
|
||||||
|
delete body.roleNames;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user