Skip to content

Commit

Permalink
Merge pull request #157 from TRIP-Side-Project/feature/#156-social
Browse files Browse the repository at this point in the history
소셜 로그인 기능 수정
  • Loading branch information
don9m1n authored Dec 28, 2023
2 parents 483b668 + f1005f3 commit 9ac9122
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;

import java.io.IOException;
import java.util.Optional;
Expand Down Expand Up @@ -58,12 +59,16 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
// OAuth2User 객체에서 권한 가져옴
JwtToken jwtToken = jwtTokenProvider.createJwtToken(member.getEmail(), member.getRole().getValue());

response.addHeader(HttpHeaders.SET_COOKIE, createCookie("accessToken", jwtToken.getAccessToken()));
response.addHeader(HttpHeaders.SET_COOKIE, createCookie("refreshToken", jwtToken.getRefreshToken()));
response.addHeader(HttpHeaders.SET_COOKIE, createCookie("memberId", String.valueOf(member.getId())));
response.addHeader(HttpHeaders.SET_COOKIE, createCookie("profileImgUrl", member.getProfileImg()));

response.sendRedirect("https://dkoqktaeu3tic.cloudfront.net/home");
String targetUrl = UriComponentsBuilder.fromUriString("https://dkoqktaeu3tic.cloudfront.net/home")
.queryParam("accessToken", jwtToken.getAccessToken())
.queryParam("refreshToken", jwtToken.getRefreshToken())
.queryParam("memberId", String.valueOf(member.getId()))
.queryParam("profileImgUrl", member.getProfileImg())
.build().toUriString();

getRedirectStrategy().sendRedirect(request, response, targetUrl);


}

private static String createCookie(String name, String value) {
Expand Down

0 comments on commit 9ac9122

Please sign in to comment.