From 67b05daf529c0be8f3c84581606e7d772bc26e32 Mon Sep 17 00:00:00 2001 From: taejin1221 Date: Tue, 10 Sep 2024 15:25:42 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=B9=B4=EC=B9=B4=EC=98=A4=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=99=84=EB=A3=8C=20=ED=9B=84=20kaboo.sit?= =?UTF-8?q?e/join=20=EC=9C=BC=EB=A1=9C=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/handler/LoginSuccessHandler.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/kaboo/kaboo_auth/domain/handler/LoginSuccessHandler.java b/src/main/java/kaboo/kaboo_auth/domain/handler/LoginSuccessHandler.java index 57d481c..82c12f3 100644 --- a/src/main/java/kaboo/kaboo_auth/domain/handler/LoginSuccessHandler.java +++ b/src/main/java/kaboo/kaboo_auth/domain/handler/LoginSuccessHandler.java @@ -2,7 +2,6 @@ import java.io.IOException; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; import org.springframework.security.core.Authentication; @@ -11,7 +10,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; -import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import kaboo.kaboo_auth.domain.dto.response.LoginSucessResponse; @@ -32,9 +30,6 @@ public class LoginSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { private final int accessTokenValidTime = 10 * 60; // 유효기간 : 10분 private final int refreshTokenValidTime = 10 * 24 * 60 * 60; // 유효기간 : 10일 - @Value("${AUTH.REDIRECT_URL}") - private String redirectURL; - private ResponseCookie createCookie(String key, String value, int maxAge) { return ResponseCookie.from(key, value) .maxAge(maxAge) @@ -60,9 +55,12 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo ObjectMapper objectMapper = new ObjectMapper(); String jsonResponse = objectMapper.writeValueAsString(loginSucessResponse); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("username", username, refreshTokenValidTime).toString()); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("accessToken", accessToken, accessTokenValidTime).toString()); - response.addHeader(HttpHeaders.SET_COOKIE, createCookie("refreshToken", refreshToken, refreshTokenValidTime).toString()); + response.addHeader(HttpHeaders.SET_COOKIE, + createCookie("username", username, refreshTokenValidTime).toString()); + response.addHeader(HttpHeaders.SET_COOKIE, + createCookie("accessToken", accessToken, accessTokenValidTime).toString()); + response.addHeader(HttpHeaders.SET_COOKIE, + createCookie("refreshToken", refreshToken, refreshTokenValidTime).toString()); // 응답 설정 response.setContentType("application/json"); @@ -70,5 +68,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo // JSON 응답을 출력 스트림에 작성 response.getWriter().write(jsonResponse); + + response.sendRedirect("https://kaboo.site/join"); } }