mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-28 08:40:05 +00:00
FIX: Update user accepting roleIds
This commit is contained in:
Generated
+7
-7
@@ -36,7 +36,7 @@
|
|||||||
"passport-hubspot-oauth2": "^1.0.3",
|
"passport-hubspot-oauth2": "^1.0.3",
|
||||||
"passport-mailchimp": "^1.1.0",
|
"passport-mailchimp": "^1.1.0",
|
||||||
"protospack": "2.5.2",
|
"protospack": "2.5.2",
|
||||||
"protospack-v2": "3.6.1",
|
"protospack-v2": "3.6.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -9015,9 +9015,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/protospack-v2": {
|
"node_modules/protospack-v2": {
|
||||||
"version": "3.6.1",
|
"version": "3.6.2",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.2.tgz",
|
||||||
"integrity": "sha512-kiulN1JFVAXGcC1lLOeXrB8DvL9gPvujXWYM+iJfoRm/SGDwSnw1LTS3Ytwxg9z55c3LiN9uli6AYXeTU30HcA==",
|
"integrity": "sha512-H1tpfCrj5cAJQFyES3+liZh0OoRUqCjLGGykEBhIOBTUGRPnr0CuU+czCjHdF/jBxO7ToTc3RS+kngX1scXyLg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
@@ -17245,9 +17245,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"protospack-v2": {
|
"protospack-v2": {
|
||||||
"version": "3.6.1",
|
"version": "3.6.2",
|
||||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.1.tgz",
|
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.6.2.tgz",
|
||||||
"integrity": "sha512-kiulN1JFVAXGcC1lLOeXrB8DvL9gPvujXWYM+iJfoRm/SGDwSnw1LTS3Ytwxg9z55c3LiN9uli6AYXeTU30HcA==",
|
"integrity": "sha512-H1tpfCrj5cAJQFyES3+liZh0OoRUqCjLGGykEBhIOBTUGRPnr0CuU+czCjHdF/jBxO7ToTc3RS+kngX1scXyLg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@grpc/grpc-js": "^1.6.7",
|
"@grpc/grpc-js": "^1.6.7",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@
|
|||||||
"passport-hubspot-oauth2": "^1.0.3",
|
"passport-hubspot-oauth2": "^1.0.3",
|
||||||
"passport-mailchimp": "^1.1.0",
|
"passport-mailchimp": "^1.1.0",
|
||||||
"protospack": "2.5.2",
|
"protospack": "2.5.2",
|
||||||
"protospack-v2": "3.6.1",
|
"protospack-v2": "3.6.2",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "^7.5.5",
|
"rxjs": "^7.5.5",
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ export class UpdateUserReq {
|
|||||||
department?: string;
|
department?: string;
|
||||||
@ApiPropertyOptional()
|
@ApiPropertyOptional()
|
||||||
hierarchy?: number;
|
hierarchy?: number;
|
||||||
|
@ApiPropertyOptional()
|
||||||
|
roleNames?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateUserRes {
|
export class UpdateUserRes {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export class UsersController {
|
|||||||
@ApiOkResponse({ type: SetUserRolesRes })
|
@ApiOkResponse({ type: SetUserRolesRes })
|
||||||
async setUserRoles(@User() user: RequestUser, @Body() body: SetUserRolesReq) {
|
async setUserRoles(@User() user: RequestUser, @Body() body: SetUserRolesReq) {
|
||||||
this.logger.info('createUser', { user });
|
this.logger.info('createUser', { user });
|
||||||
return await this.userService.setRoles(body);
|
return await this.userService.setRoles(body, user.customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Put('role')
|
@Put('role')
|
||||||
@@ -143,6 +143,6 @@ export class UsersController {
|
|||||||
@Param('id') id: string,
|
@Param('id') id: string,
|
||||||
) {
|
) {
|
||||||
this.logger.info('updateUser', { user });
|
this.logger.info('updateUser', { user });
|
||||||
return await this.userService.updateUser(body, id);
|
return await this.userService.updateUser(body, id, user.customer_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,11 @@ export class UsersService implements OnModuleInit {
|
|||||||
return { user };
|
return { user };
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateUser(req: UpdateUserReq, id: string) {
|
async updateUser(req: UpdateUserReq, id: string, customerId: string) {
|
||||||
const { department, hierarchy, jobTitle, name } = req;
|
const { department, hierarchy, jobTitle, name, roleNames } = req;
|
||||||
|
if (roleNames) {
|
||||||
|
await this.setRoles({ roleNames, userId: id }, customerId);
|
||||||
|
}
|
||||||
const { user } = await lastValueFrom(
|
const { user } = await lastValueFrom(
|
||||||
this.usersClientService.UserUpdate({
|
this.usersClientService.UserUpdate({
|
||||||
name,
|
name,
|
||||||
@@ -106,7 +109,7 @@ export class UsersService implements OnModuleInit {
|
|||||||
return { user };
|
return { user };
|
||||||
}
|
}
|
||||||
|
|
||||||
async setRoles(body: SetUserRolesReq) {
|
async setRoles(body: SetUserRolesReq, customerId: string) {
|
||||||
const { roleNames, userId } = body;
|
const { roleNames, userId } = body;
|
||||||
const clearRoles = roleNames && roleNames.length === 0;
|
const clearRoles = roleNames && roleNames.length === 0;
|
||||||
const { user } = await lastValueFrom(
|
const { user } = await lastValueFrom(
|
||||||
@@ -115,6 +118,7 @@ export class UsersService implements OnModuleInit {
|
|||||||
roleIds: [],
|
roleIds: [],
|
||||||
roleNames,
|
roleNames,
|
||||||
clearRoles,
|
clearRoles,
|
||||||
|
customerId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|||||||
Reference in New Issue
Block a user