fix
This commit is contained in:
parent
bed7dbb896
commit
a213d75c70
2 changed files with 13 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,9 +214,9 @@ export async function updateName(
|
|||
userId: string,
|
||||
firstName: string,
|
||||
lastName: string,
|
||||
opts: Record<string, any>,
|
||||
// opts: Record<string, any>,
|
||||
) {
|
||||
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()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue