From 860989c3cf79d7ce724858e25f712b6bc4250b4e Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 14 Jun 2024 13:21:43 +0700 Subject: [PATCH] fix test --- src/controllers/ProfileChangeNameController.ts | 15 ++++++--------- src/keycloak/index.ts | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index c9ca7158..628e2c20 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -147,15 +147,12 @@ export class ProfileChangeNameController extends Controller { profile.prefix = body.prefix ?? profile.prefix; await this.profileRepository.save(profile); - // if (profile != null) { - // const result = await updateName(profile.id, profile.firstName, profile.lastName,req); - - // const _mapData = { - // data: mappedData, - // total: total, - // }; - - // } + if (profile != null && profile.keycloak != null) { + const result = await updateName(profile.keycloak, profile.firstName, profile.lastName, req); + if (!result) { + throw new Error(result.errorMessage); + } + } return new HttpSuccess(data.id); } diff --git a/src/keycloak/index.ts b/src/keycloak/index.ts index 240ff947..33649095 100644 --- a/src/keycloak/index.ts +++ b/src/keycloak/index.ts @@ -229,6 +229,8 @@ export async function updateName( enabled: true, credentials: (password && [{ type: "password", value: opts?.password }]) || undefined, ...rest, + firstName, + lastName, }), }).catch((e) => console.log("Keycloak Error: ", e));