From 922c52d8079f76bdb93ef3a45d32e41d4bdda142 Mon Sep 17 00:00:00 2001 From: potados99 Date: Sat, 19 Feb 2022 22:35:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20400=20=ED=8F=AC=ED=95=A8=ED=95=9C=20?= =?UTF-8?q?=EA=B8=B0=ED=83=80=20=EC=9D=91=EB=8B=B5=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- lib/application/user/common/errors.ts | 23 +++++++++++++++++---- lib/external/inu/StudentAccountValidator.ts | 11 +++++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d365ceb9..1ba8f707 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ ## 업데이트 로그 -### 2022.2.19 v2.3.9 +### 2022.2.19 v2.3.10 - 수료 또는 졸업생에게 표시되는 로그인 메시지 세분화. ### 2022.2.19 v2.3.8 diff --git a/lib/application/user/common/errors.ts b/lib/application/user/common/errors.ts index 115b884b..d97ae85a 100644 --- a/lib/application/user/common/errors.ts +++ b/lib/application/user/common/errors.ts @@ -17,7 +17,12 @@ * along with this program. If not, see . */ -import {BadRequest, Forbidden, Unauthorized} from '@inu-cafeteria/backend-core'; +import { + BadRequest, + Forbidden, + InternalServerError, + Unauthorized, +} from '@inu-cafeteria/backend-core'; export const UserNotExist = BadRequest.of('user_not_exist', '사용자가 존재하지 않습니다.'); @@ -35,6 +40,16 @@ export const InvalidPhoneNumber = BadRequest.of( '잘못된 휴대전화번호 형식입니다!' ); +export const InvalidPasscode = BadRequest.of( + 'invalid_passcode', + '인증번호가 만료되었거나 올바르지 않습니다 😯' +); + +export const BadFormedCredentials = BadRequest.of( + 'bad_formed_credentials', + '올바른 학번과 비밀번호를 입력해주세요 😉' +); + export const InvalidCredentials = Unauthorized.of( 'invalid_credentials', '학번과 비밀번호를 확인해 주세요 😉' @@ -45,7 +60,7 @@ export const ForUndergraduatesOnly = Forbidden.of( '수료 또는 졸업하신 경우 서비스 이용이 어렵습니다 😢' ); -export const InvalidPasscode = BadRequest.of( - 'invalid_passcode', - '인증번호가 만료되었거나 올바르지 않습니다 😯' +export const StudentLoginUnavailable = InternalServerError.of( + 'student_login_unavailable', + '로그인 서버에 문제가 생겼습니다 🤯' ); diff --git a/lib/external/inu/StudentAccountValidator.ts b/lib/external/inu/StudentAccountValidator.ts index bd0c6fdb..4ffad913 100644 --- a/lib/external/inu/StudentAccountValidator.ts +++ b/lib/external/inu/StudentAccountValidator.ts @@ -21,7 +21,12 @@ import config from '../../../config'; import {logger} from '@inu-cafeteria/backend-core'; import {postUrlencoded} from '../../common/utils/fetch'; import {encryptForRemoteLogin} from '../../common/utils/encrypt'; -import {ForUndergraduatesOnly, InvalidCredentials} from '../../application/user/common/errors'; +import { + BadFormedCredentials, + ForUndergraduatesOnly, + InvalidCredentials, + StudentLoginUnavailable, +} from '../../application/user/common/errors'; export default class StudentAccountValidator { constructor(private readonly studentId: string, private readonly password: string) {} @@ -46,10 +51,14 @@ export default class StudentAccountValidator { switch (response.status) { case 200: break; + case 400: + throw BadFormedCredentials(); case 401: throw InvalidCredentials(); case 403: throw ForUndergraduatesOnly(); + default: + throw StudentLoginUnavailable(); } }