errorMessage

This commit is contained in:
Bright 2024-05-30 14:16:00 +07:00
parent bb9407ad38
commit aef313bac7
2 changed files with 13 additions and 4 deletions

View file

@ -88,7 +88,8 @@ export class KeycloakController extends Controller {
});
if (typeof userId !== "string") {
throw new Error("ไม่สามารถติดต่อกับระบบจัดการผู้ใช้งานได้");
// throw new Error("ไม่สามารถติดต่อกับระบบจัดการผู้ใช้งานได้");
throw new Error(userId.errorMessage);
}
const now = new Date().toISOString();
@ -140,9 +141,15 @@ export class KeycloakController extends Controller {
firstName?: string;
lastName?: string;
email?: string;
attributes?: object
},
) {
return await editUser(userId, body);
// return await editUser(userId, body);
const chkUpdate = await editUser(userId, body);
if (typeof chkUpdate !== "boolean") {
throw new Error(chkUpdate.errorMessage);
}
return chkUpdate
}
@Delete("user/{userId}")

View file

@ -85,7 +85,8 @@ export async function createUser(username: string, password: string, opts?: Reco
if (!res) return false;
if (!res.ok) {
return Boolean(console.error("Keycloak Error Response: ", await res.json()));
// return Boolean(console.error("Keycloak Error Response: ", await res.json()));
return await res.json();
}
const path = res.headers.get("Location");
@ -174,7 +175,8 @@ export async function editUser(userId: string, opts: Record<string, any>) {
if (!res) return false;
if (!res.ok) {
return Boolean(console.error("Keycloak Error Response: ", await res.json()));
// return Boolean(console.error("Keycloak Error Response: ", await res.json()));
return await res.json();
}
const path = res.headers.get("Location");