Skip to content

Commit

Permalink
fix: search type
Browse files Browse the repository at this point in the history
  • Loading branch information
GitJIHO committed Nov 15, 2024
1 parent a7295ac commit 0967bfb
Showing 1 changed file with 26 additions and 30 deletions.
56 changes: 26 additions & 30 deletions src/main/java/com/gdg/kkia/auth/service/KakaoApiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@ public class KakaoApiService {
private final KakaoProperties kakaoProperties;

public String getAuthorizationUrl(HttpServletRequest httpServletRequest) {
// String requestUrl = httpServletRequest.getHeader("Origin");
// if (requestUrl == null) {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
// }
// String redirectUri;
//
// if (requestUrl.contains(LOCALHOST_URL)) {
// redirectUri = kakaoProperties.devRedirectUri();
// } else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
// redirectUri = kakaoProperties.redirectUri();
// } else {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
// }

String redirectUri = "http://localhost:5173/redirection";
String requestUrl = httpServletRequest.getHeader("Host");
if (requestUrl == null) {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
}
String redirectUri;

if (requestUrl.contains(LOCALHOST_URL)) {
redirectUri = kakaoProperties.devRedirectUri();
} else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
redirectUri = kakaoProperties.redirectUri();
} else {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
}

return KAKAO_AUTH_BASE_URL + "/authorize?response_type=code&client_id="
+ kakaoProperties.clientId() + "&redirect_uri=" + redirectUri;
Expand All @@ -53,21 +51,19 @@ public KakaoTokenResponse getAccessToken(String authorizationCode, HttpServletRe
HttpHeaders headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);

// String requestUrl = httpServletRequest.getHeader("Origin");
// if (requestUrl == null) {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
// }
// String redirectUri;
//
// if (requestUrl.contains(LOCALHOST_URL)) {
// redirectUri = kakaoProperties.devRedirectUri();
// } else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
// redirectUri = kakaoProperties.redirectUri();
// } else {
// throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
// }

String redirectUri = "http://localhost:5173/redirection";
String requestUrl = httpServletRequest.getHeader("Host");
if (requestUrl == null) {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다.");
}
String redirectUri;

if (requestUrl.contains(LOCALHOST_URL)) {
redirectUri = kakaoProperties.devRedirectUri();
} else if (requestUrl.contains(kakaoProperties.frontUriWithoutHttp())) {
redirectUri = kakaoProperties.redirectUri();
} else {
throw new BadRequestException("해당 도메인에서는 카카오 로그인이 불가합니다. requestUrl : " + requestUrl);
}

LinkedMultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.add("grant_type", "authorization_code");
Expand Down

0 comments on commit 0967bfb

Please sign in to comment.