From 76e2ee5e0d679db64f1633af2a46c2d8e4eb8b98 Mon Sep 17 00:00:00 2001 From: jiyunio Date: Sun, 6 Oct 2024 01:08:11 +0900 Subject: [PATCH] =?UTF-8?q?[Fix]=20oauth=20success=20url=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/appcenter/BJJ/oauth/OAuth2SuccessHandler.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/appcenter/BJJ/oauth/OAuth2SuccessHandler.java b/src/main/java/com/appcenter/BJJ/oauth/OAuth2SuccessHandler.java index dca3447..030fe21 100644 --- a/src/main/java/com/appcenter/BJJ/oauth/OAuth2SuccessHandler.java +++ b/src/main/java/com/appcenter/BJJ/oauth/OAuth2SuccessHandler.java @@ -2,7 +2,6 @@ import com.appcenter.BJJ.jwt.JwtProvider; import com.appcenter.BJJ.jwt.UserDetailsImpl; -import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; @@ -21,26 +20,24 @@ public class OAuth2SuccessHandler implements AuthenticationSuccessHandler { private final JwtProvider jwtProvider; //로그인 성공 및 토큰 발급 및 redirect url - @Value("${spring.server.host}") - private String domain; @Value("${spring.oauth2.url.sign_in}") private String signInUrl; @Value("${spring.oauth2.url.sign_up}") private String signUpUrl; @Override - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { log.info("OAuth2SuccessHandler 진입"); UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal(); String token = jwtProvider.generateToken(authentication, JwtProvider.validAccessTime); String redirectUrl; if (userDetails.getMember().getRole().equals("ROLE_GUEST")) { log.info("OAuth2SuccessHandler-onAuthenticationSuccess: 회원가입으로 이동"); - redirectUrl = UriComponentsBuilder.fromHttpUrl(domain + signUpUrl) + redirectUrl = UriComponentsBuilder.fromHttpUrl(signUpUrl) .queryParam("token", token).toUriString(); } else { log.info("OAuth2SuccessHandler-onAuthenticationSuccess: 로그인으로 이동"); - redirectUrl = UriComponentsBuilder.fromHttpUrl(domain + signInUrl) + redirectUrl = UriComponentsBuilder.fromHttpUrl(signInUrl) .queryParam("token", token).toUriString(); } response.sendRedirect(redirectUrl);