FIX: Update user accepting roleIds

This commit is contained in:
Gabriel Rosa
2022-07-19 10:17:57 -03:00
parent 57f47d3b2e
commit 9cdb0a5d38
5 changed files with 19 additions and 13 deletions
+7 -3
View File
@@ -85,8 +85,11 @@ export class UsersService implements OnModuleInit {
return { user };
}
async updateUser(req: UpdateUserReq, id: string) {
const { department, hierarchy, jobTitle, name } = req;
async updateUser(req: UpdateUserReq, id: string, customerId: string) {
const { department, hierarchy, jobTitle, name, roleNames } = req;
if (roleNames) {
await this.setRoles({ roleNames, userId: id }, customerId);
}
const { user } = await lastValueFrom(
this.usersClientService.UserUpdate({
name,
@@ -106,7 +109,7 @@ export class UsersService implements OnModuleInit {
return { user };
}
async setRoles(body: SetUserRolesReq) {
async setRoles(body: SetUserRolesReq, customerId: string) {
const { roleNames, userId } = body;
const clearRoles = roleNames && roleNames.length === 0;
const { user } = await lastValueFrom(
@@ -115,6 +118,7 @@ export class UsersService implements OnModuleInit {
roleIds: [],
roleNames,
clearRoles,
customerId,
}),
);
if (user) {