From 4bfde62a680c9a18719650eef70df5d306e11bbb Mon Sep 17 00:00:00 2001 From: Jin Hyuk Date: Tue, 8 Oct 2024 20:58:53 +0900 Subject: [PATCH] =?UTF-8?q?feat/#507:=20"refreshToken"=20=EB=AC=B8?= =?UTF-8?q?=EC=9E=90=EC=97=B4=20=EC=83=81=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gaebaljip/exceed/adapter/in/auth/AuthController.java | 7 ++++--- .../com/gaebaljip/exceed/common/EatCeedStaticMessage.java | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BE/exceed/src/main/java/com/gaebaljip/exceed/adapter/in/auth/AuthController.java b/BE/exceed/src/main/java/com/gaebaljip/exceed/adapter/in/auth/AuthController.java index ead1c831..5260fcb2 100644 --- a/BE/exceed/src/main/java/com/gaebaljip/exceed/adapter/in/auth/AuthController.java +++ b/BE/exceed/src/main/java/com/gaebaljip/exceed/adapter/in/auth/AuthController.java @@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import com.gaebaljip.exceed.common.EatCeedStaticMessage; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -75,21 +76,21 @@ public ApiResponse> logout( } private void setCookie(HttpServletResponse response, String refreshToken) { - Cookie cookie = new Cookie("refreshToken", refreshToken); + Cookie cookie = new Cookie(EatCeedStaticMessage.REFRESH_TOKEN, refreshToken); cookie.setHttpOnly(true); cookie.setSecure(true); response.addCookie(cookie); } private void deleteRefreshCookie(HttpServletResponse response) { - Cookie cookie = new Cookie("refreshToken", null); + Cookie cookie = new Cookie(EatCeedStaticMessage.REFRESH_TOKEN, null); cookie.setMaxAge(0); response.addCookie(cookie); } private Cookie getCookie(Cookie[] cookies) { for (Cookie cookie : cookies) { - if (cookie.getName().equals("refreshToken")) { + if (cookie.getName().equals(EatCeedStaticMessage.REFRESH_TOKEN)) { return cookie; } } diff --git a/BE/exceed/src/main/java/com/gaebaljip/exceed/common/EatCeedStaticMessage.java b/BE/exceed/src/main/java/com/gaebaljip/exceed/common/EatCeedStaticMessage.java index 074ed8f2..4aebeec7 100644 --- a/BE/exceed/src/main/java/com/gaebaljip/exceed/common/EatCeedStaticMessage.java +++ b/BE/exceed/src/main/java/com/gaebaljip/exceed/common/EatCeedStaticMessage.java @@ -3,4 +3,6 @@ public class EatCeedStaticMessage { public static final String REDIS_AUTO_COMPLETE_KEY = "autoComplete"; public static final String REDIS_REFRESH_TOKEN_KEY = "refresh_"; + + public static final String REFRESH_TOKEN = "refreshToken"; }