diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index f4efc7b2..ae4c900f 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -147,12 +147,12 @@ export class ProfileChangeNameController extends Controller { profile.prefix = body.prefix ?? profile.prefix; await this.profileRepository.save(profile); - // if (profile != null && profile.keycloak != null) { - // const result = await updateName(profile.keycloak, profile.firstName, profile.lastName, req); - // if (!result) { - // throw new Error(result.errorMessage); - // } - // } + if (profile != null && profile.keycloak != null) { + const result = await updateName(profile.keycloak, profile.firstName, profile.lastName); + 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 33649095..e9c82848 100644 --- a/src/keycloak/index.ts +++ b/src/keycloak/index.ts @@ -214,9 +214,9 @@ export async function updateName( userId: string, firstName: string, lastName: string, - opts: Record, + // opts: Record, ) { - const { password, ...rest } = opts; + // const { password, ...rest } = opts; const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/users/${userId}`, { // prettier-ignore @@ -227,13 +227,15 @@ export async function updateName( method: "PUT", body: JSON.stringify({ enabled: true, - credentials: (password && [{ type: "password", value: opts?.password }]) || undefined, - ...rest, + // credentials: (password && [{ type: "password", value: opts?.password }]) || undefined, + // ...rest, firstName, lastName, }), }).catch((e) => console.log("Keycloak Error: ", e)); - + console.log("firstName: ", firstName); + console.log("lastName: ", lastName); + if (!res) return false; if (!res.ok) { // return Boolean(console.error("Keycloak Error Response: ", await res.json()));