Skip to content

Commit

Permalink
fix: 400 포함한 기타 응답 대응
Browse files Browse the repository at this point in the history
  • Loading branch information
potados99 committed Feb 19, 2022
1 parent ab3bd7d commit 922c52d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

## 업데이트 로그

### 2022.2.19 v2.3.9
### 2022.2.19 v2.3.10
- 수료 또는 졸업생에게 표시되는 로그인 메시지 세분화.

### 2022.2.19 v2.3.8
Expand Down
23 changes: 19 additions & 4 deletions lib/application/user/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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', '사용자가 존재하지 않습니다.');

Expand All @@ -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',
'학번과 비밀번호를 확인해 주세요 😉'
Expand All @@ -45,7 +60,7 @@ export const ForUndergraduatesOnly = Forbidden.of(
'수료 또는 졸업하신 경우 서비스 이용이 어렵습니다 😢'
);

export const InvalidPasscode = BadRequest.of(
'invalid_passcode',
'인증번호가 만료되었거나 올바르지 않습니다 😯'
export const StudentLoginUnavailable = InternalServerError.of(
'student_login_unavailable',
'로그인 서버에 문제가 생겼습니다 🤯'
);
11 changes: 10 additions & 1 deletion lib/external/inu/StudentAccountValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 922c52d

Please sign in to comment.