From 728d0879f330a2fb2a9e17b778e446daa3cd79ab Mon Sep 17 00:00:00 2001 From: SeonghunYang Date: Mon, 16 Sep 2024 11:18:21 +0000 Subject: [PATCH 1/2] fix: update authentication error messages for better clarity --- app/business/services/user/user.command.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/business/services/user/user.command.ts b/app/business/services/user/user.command.ts index 77655aad..8d9b3fc0 100644 --- a/app/business/services/user/user.command.ts +++ b/app/business/services/user/user.command.ts @@ -125,7 +125,15 @@ export async function authenticate(prevState: FormState, formData: FormData): Pr isSuccess: false, isFailure: true, validationError: {}, - message: error.message, + message: '아이디 또는 비밀번호가 일치하지 않습니다.', + }; + } else if (error instanceof BadRequestError) { + // 잘못된 요청 처리 로직 + return { + isSuccess: false, + isFailure: true, + validationError: {}, + message: '존재하지 않는 계정입니다', }; } else { // 나머지 에러는 더 상위 수준에서 처리 From e11fe1d086532e281f21348ee30f8d044711f659 Mon Sep 17 00:00:00 2001 From: SeonghunYang Date: Fri, 20 Sep 2024 13:10:37 +0000 Subject: [PATCH 2/2] fix: enhance error handling in authentication to include BadRequestError --- app/business/services/user/user.command.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/business/services/user/user.command.ts b/app/business/services/user/user.command.ts index 8d9b3fc0..a37ce90b 100644 --- a/app/business/services/user/user.command.ts +++ b/app/business/services/user/user.command.ts @@ -119,7 +119,7 @@ export async function authenticate(prevState: FormState, formData: FormData): Pr } } catch (error) { // 명세와 다르게 에러가 발생할 경우 BadRequestError가 아니라 UnauthorizedError가 발생 - if (error instanceof UnauthorizedError) { + if (error instanceof UnauthorizedError || error instanceof BadRequestError) { // 잘못된 요청 처리 로직 return { isSuccess: false, @@ -127,14 +127,6 @@ export async function authenticate(prevState: FormState, formData: FormData): Pr validationError: {}, message: '아이디 또는 비밀번호가 일치하지 않습니다.', }; - } else if (error instanceof BadRequestError) { - // 잘못된 요청 처리 로직 - return { - isSuccess: false, - isFailure: true, - validationError: {}, - message: '존재하지 않는 계정입니다', - }; } else { // 나머지 에러는 더 상위 수준에서 처리 throw error;