Skip to content

Commit 58d6d56

Browse files
authored
Dev > Main 브랜치 병합
1. 일정 정지 횟수가 됐을 때 로그인 하면 로그인이 되지 않는 오류 기능을 구현하였습니다. 통합 테스트 후 Main 브랜치로 병합합니다.
2 parents 3297fb9 + 71dcbcb commit 58d6d56

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/main/java/hs/kr/backend/devpals/domain/auth/service/AuthService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.springframework.transaction.annotation.Transactional;
2929

3030
import java.time.LocalDate;
31+
import java.time.LocalDateTime;
32+
import java.time.format.DateTimeFormatter;
3133
import java.util.concurrent.TimeUnit;
3234

3335
@Service
@@ -52,6 +54,16 @@ public ResponseEntity<LoginResponse<TokenResponse>> login(LoginRequest request)
5254
throw new CustomException(ErrorException.INVALID_PASSWORD);
5355
}
5456

57+
if (user.isPermanentlyBanned()) {
58+
throw new CustomException(ErrorException.PERMANENTLY_BANNED); // 메시지: 영구 정지된 계정입니다.
59+
}
60+
61+
if (user.getBannedUntil() != null && user.getBannedUntil().isAfter(LocalDateTime.now())) {
62+
String endTime = user.getBannedUntil().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
63+
throw new CustomException(ErrorException.TEMP_BANNED,
64+
"정지된 계정입니다. 해제일: " + endTime);
65+
}
66+
5567
// AccessToken, RefreshToken 생성
5668
String accessToken = jwtTokenProvider.generateToken(user.getId());
5769
String refreshToken = jwtTokenProvider.generateRefreshToken(user.getId());

src/main/java/hs/kr/backend/devpals/global/exception/CustomException.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ public CustomException(ErrorException errorException) {
1414
this.message = errorException.getMessage();
1515
}
1616

17+
public CustomException(ErrorException errorException, String customMessage) {
18+
super(customMessage);
19+
this.code = errorException.getCode();
20+
this.message = customMessage;
21+
}
22+
1723
@Override
1824
public String toString() {
1925
return "CustomException{" +

src/main/java/hs/kr/backend/devpals/global/exception/ErrorException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public enum ErrorException {
3636
NOT_COMMENT_OWNER(403, "작성자 및 프로젝트 작성자만 댓글을 삭제할 수 있습니다."),
3737
NOT_INQUIRY_DELETE(403, "문의글을 삭제할 권한이 없습니다."),
3838
NO_PERMISSION(403, "관리자 기능입니다."),
39+
PERMANENTLY_BANNED(403, "영구 정지된 계정입니다. 관리자에게 문의해주세요."),
40+
TEMP_BANNED(403, "정지된 계정입니다."),
3941

4042
ALARM_FILTER_NOT_FOUND(404, "알람 필터값이 존재하지 않습니다."),
4143
ALARM_NOT_FOUND(404, "알람이 존재하지 않습니다."),

0 commit comments

Comments
 (0)