Skip to content

Commit

Permalink
Merge pull request #28 from goalSetter09/10th-Kampus-BE-27
Browse files Browse the repository at this point in the history
[FIX] 소셜 로그인 성공 후 리다이렉션
  • Loading branch information
goalSetter09 authored Jan 12, 2025
2 parents b176bab + 807f9b7 commit b42f6b6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.cotato.kampus.global.auth.oauth.handler;

import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;

Expand Down Expand Up @@ -30,10 +31,11 @@ public class OAuthSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
private static final String TOKEN_PREFIX = "Bearer";
private static final Long ACCESS_TOKEN_EXP = 6000000L;
private static final Long REFRESH_TOKEN_EXP = 86400000L;
private static final String REDIRECT_URL = "http://localhost:3000/oauth-success";

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) {
Authentication authentication) throws IOException {

CustomOAuth2User customOAuth2User = (CustomOAuth2User)authentication.getPrincipal();

Expand All @@ -55,5 +57,7 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
// Bearer 토큰을 헤더에 추가
response.setHeader(ACCESS_HEADER_NAME, TOKEN_PREFIX + access);
response.setHeader(REFRESH_HEADER_NAME, TOKEN_PREFIX + refresh);
response.sendRedirect(REDIRECT_URL + "?accessToken=" + access
+ "&refreshToken=" + refresh);
}
}

0 comments on commit b42f6b6

Please sign in to comment.