Skip to content

Commit

Permalink
Merge pull request #147 from CLAT-Project/feat-OAuth2_Detail
Browse files Browse the repository at this point in the history
test : redirect test
  • Loading branch information
AKKDevMachine authored Jan 23, 2025
2 parents 996ed9c + 38dea47 commit ccffcdd
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import team_project.clat.dto.CustomOAuth2User;

import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -53,11 +58,30 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
response.getWriter().write(jsonResponse); // ์‘๋‹ต ์ „์†ก*/

// ๋ฆฌ๋””๋ ‰์…˜ URL ์„ค์ •
/* // ๋ฆฌ๋””๋ ‰์…˜ URL ์„ค์ •
String redirectUrl = "https://clat-project.vercel.app/social-login";
redirectUrl += "?success=true&username=" + username + "&name=" + name + "&email=" + email;
redirectUrl += "?success=true&username=" + username + "&name=" + name + "&email=" + email;*/

// ๋ฆฌ๋””๋ ‰์…˜
response.sendRedirect(redirectUrl);
/* // ๋ฆฌ๋””๋ ‰์…˜
response.sendRedirect(redirectUrl);*/

String encodedName = URLEncoder.encode(name, StandardCharsets.UTF_8);

MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
queryParams.add("success", "true");
queryParams.add("username", username);
queryParams.add("name", encodedName);
queryParams.add("email", email);

String uri = UriComponentsBuilder
.newInstance()
.scheme("https")
.host("clat-project.vercel.app")
.path("/social-login")
.queryParams(queryParams)
.build()
.toString();

getRedirectStrategy().sendRedirect(request,response,uri);
}
}

0 comments on commit ccffcdd

Please sign in to comment.