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;
|
profile.prefix = body.prefix ?? profile.prefix;
|
||||||
await this.profileRepository.save(profile);
|
await this.profileRepository.save(profile);
|
||||||
|
|
||||||
// if (profile != null && profile.keycloak != null) {
|
if (profile != null && profile.keycloak != null) {
|
||||||
// const result = await updateName(profile.keycloak, profile.firstName, profile.lastName, req);
|
const result = await updateName(profile.keycloak, profile.firstName, profile.lastName);
|
||||||
// if (!result) {
|
if (!result) {
|
||||||
// throw new Error(result.errorMessage);
|
throw new Error(result.errorMessage);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
return new HttpSuccess(data.id);
|
return new HttpSuccess(data.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,9 +214,9 @@ export async function updateName(
|
||||||
userId: string,
|
userId: string,
|
||||||
firstName: string,
|
firstName: string,
|
||||||
lastName: 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}`, {
|
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/users/${userId}`, {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
|
|
@ -227,13 +227,15 @@ export async function updateName(
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
credentials: (password && [{ type: "password", value: opts?.password }]) || undefined,
|
// credentials: (password && [{ type: "password", value: opts?.password }]) || undefined,
|
||||||
...rest,
|
// ...rest,
|
||||||
firstName,
|
firstName,
|
||||||
lastName,
|
lastName,
|
||||||
}),
|
}),
|
||||||
}).catch((e) => console.log("Keycloak Error: ", e));
|
}).catch((e) => console.log("Keycloak Error: ", e));
|
||||||
|
console.log("firstName: ", firstName);
|
||||||
|
console.log("lastName: ", lastName);
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
// return Boolean(console.error("Keycloak Error Response: ", await res.json()));
|
// return Boolean(console.error("Keycloak Error Response: ", await res.json()));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue