From 3540438de241c5b1b9484a9e3fcd6a50c50c2f62 Mon Sep 17 00:00:00 2001 From: Gyuhyeok99 Date: Fri, 30 Jan 2026 13:59:59 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=A6=AC=ED=94=84=EB=A0=88?= =?UTF-8?q?=EC=8B=9C=20=ED=86=A0=ED=81=B0=20=EB=A7=8C=EB=A3=8C=EC=8B=9C=20?= =?UTF-8?q?=EC=BF=A0=ED=82=A4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthController.java | 14 +++++++++++--- .../common/exception/CustomException.java | 11 +++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/example/solidconnection/auth/controller/AuthController.java b/src/main/java/com/example/solidconnection/auth/controller/AuthController.java index 9fbd2f225..f3b6e9c2c 100644 --- a/src/main/java/com/example/solidconnection/auth/controller/AuthController.java +++ b/src/main/java/com/example/solidconnection/auth/controller/AuthController.java @@ -118,11 +118,19 @@ public ResponseEntity quit( @PostMapping("/reissue") public ResponseEntity reissueToken( - HttpServletRequest request + HttpServletRequest request, + HttpServletResponse response ) { String refreshToken = refreshTokenCookieManager.getRefreshToken(request); - ReissueResponse reissueResponse = authService.reissue(refreshToken); - return ResponseEntity.ok(reissueResponse); + try { + ReissueResponse reissueResponse = authService.reissue(refreshToken); + return ResponseEntity.ok(reissueResponse); + } catch (CustomException e) { + if (e.getErrorCode().equals(ErrorCode.REFRESH_TOKEN_EXPIRED)) { + refreshTokenCookieManager.deleteCookie(response); + } + throw e; + } } private String getAccessToken(Authentication authentication) { diff --git a/src/main/java/com/example/solidconnection/common/exception/CustomException.java b/src/main/java/com/example/solidconnection/common/exception/CustomException.java index fab42924c..eb596f8cf 100644 --- a/src/main/java/com/example/solidconnection/common/exception/CustomException.java +++ b/src/main/java/com/example/solidconnection/common/exception/CustomException.java @@ -5,16 +5,19 @@ @Getter public class CustomException extends RuntimeException { + private final ErrorCode errorCode; private final int code; private final String message; public CustomException(ErrorCode errorCode) { - code = errorCode.getCode(); - message = errorCode.getMessage(); + this.errorCode = errorCode; + this.code = errorCode.getCode(); + this.message = errorCode.getMessage(); } public CustomException(ErrorCode errorCode, String detail) { - code = errorCode.getCode(); - message = errorCode.getMessage() + " : " + detail; + this.errorCode = errorCode; + this.code = errorCode.getCode(); + this.message = errorCode.getMessage() + " : " + detail; } }