From f7653aa4cfc852c41fbcea1fa7d4e31b6179f9b6 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 4 Dec 2024 15:46:20 +0700 Subject: [PATCH] fix command 08 --- src/controllers/CommandController.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 2dc27465..30ef838f 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2240,8 +2240,8 @@ export class CommandController extends Controller { firstName: profile.firstName, lastName: profile.lastName, }); - // กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ - if (profile.keycloak != null && userKeycloakId && userKeycloakId.error === "User exists with same username") { + // กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error + if (profile.keycloak != null && userKeycloakId && userKeycloakId.errorMessage === "User exists with same username") { const delUserKeycloak = await deleteUser(profile.keycloak); if(delUserKeycloak) { userKeycloakId = await createUser(profile.citizenId, profile.citizenId, { @@ -2249,6 +2249,9 @@ export class CommandController extends Controller { lastName: profile.lastName, }); } + else { + throw new HttpError(HttpStatus.BAD_REQUEST, "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้"); + } } const list = await getRoles(); let result = false;