Skip to content

Commit 043cea1

Browse files
committed
refactor: 비 로그인 제출 요청 방어 로직 추가
1 parent eeda6ed commit 043cea1

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public class SubmissionService {
5656
private final GitHubPushService gitHubPushService;
5757

5858
public SubmitResponse prepareSubmission(Long problemId, AuthUser authUser) {
59+
60+
if (authUser == null) {
61+
throw new SubmissionException(SubmissionExceptionCode.AUTH_REQUIRED);
62+
}
63+
5964
boolean acquired = lockManager.tryLock("submission", authUser.getId(), problemId);
6065
if (!acquired) {
6166
throw new SubmissionException(SubmissionExceptionCode.ALREADY_JUDGING);

src/main/java/org/ezcode/codetest/domain/submission/exception/code/SubmissionExceptionCode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum SubmissionExceptionCode implements ResponseCode {
1717
TESTCASE_TIMEOUT(false, HttpStatus.GATEWAY_TIMEOUT, "테스트케이스 채점 시간이 초과되었습니다."),
1818
REDIS_SERVER_ERROR(false, HttpStatus.INTERNAL_SERVER_ERROR, "Redis 서버 연결 실패"),
1919
ALREADY_JUDGING(false, HttpStatus.CONFLICT, "이미 해당 문제에 대한 채점이 진행 중입니다."),
20+
AUTH_REQUIRED(false, HttpStatus.UNAUTHORIZED, "로그인 후 이용해주세요."),
2021
UNKNOWN_ERROR(false, HttpStatus.INTERNAL_SERVER_ERROR, "알 수 없는 예외가 발생했습니다."),
2122
;
2223
private final boolean success;

0 commit comments

Comments
 (0)