File tree Expand file tree Collapse file tree
src/main/java/hs/kr/backend/devpals Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828import org .springframework .transaction .annotation .Transactional ;
2929
3030import java .time .LocalDate ;
31+ import java .time .LocalDateTime ;
32+ import java .time .format .DateTimeFormatter ;
3133import 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 ());
Original file line number Diff line number Diff 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{" +
Original file line number Diff line number Diff 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 , "알람이 존재하지 않습니다." ),
You can’t perform that action at this time.
0 commit comments