Skip to content

Commit

Permalink
Fix: 카카오 로그인 완료 시 메인 페이지로 redirect
Browse files Browse the repository at this point in the history
Related to: #1
  • Loading branch information
Taejin1221 authored Sep 8, 2024
1 parent 60647d2 commit 26b9781
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
Expand All @@ -26,6 +27,9 @@ 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}")
String redirectURL;

private Cookie createCookie(String key, String value, int maxAge) {
Cookie cookie = new Cookie(key, value);
cookie.setMaxAge(maxAge);
Expand All @@ -49,6 +53,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
response.addCookie(createCookie("Username", username, refreshTokenValidTime));
response.addCookie(createCookie("Authorization", accessToken, accessTokenValidTime));
response.addCookie(createCookie("RefreshToken", refreshToken, refreshTokenValidTime));
response.sendRedirect("/");
response.sendRedirect(redirectURL);
}
}

0 comments on commit 26b9781

Please sign in to comment.