Skip to content

Commit

Permalink
[fix] fix kakao unlink body
Browse files Browse the repository at this point in the history
  • Loading branch information
tkdwns414 committed Jun 7, 2024
1 parent f8f1330 commit 75b4e81
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/telepigeon/server/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.telepigeon.server.resolver.UserIdArgumentResolver;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand All @@ -17,4 +19,9 @@ public class WebConfig implements WebMvcConfigurer {
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(userIdArgumentResolver);
}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new FormHttpMessageConverter());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.telepigeon.server.oauth.dto;
package com.telepigeon.server.dto.oauth.request;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.telepigeon.server.domain.User;
import com.telepigeon.server.dto.auth.response.JwtTokensDto;
import com.telepigeon.server.dto.auth.SocialUserInfoDto;
import com.telepigeon.server.oauth.service.KakaoService;
import com.telepigeon.server.service.external.KakaoService;
import com.telepigeon.server.service.user.UserRemover;
import com.telepigeon.server.service.user.UserRetriever;
import com.telepigeon.server.service.user.UserSaver;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.telepigeon.server.oauth.service;
package com.telepigeon.server.service.external;

import com.telepigeon.server.constant.AuthConstant;
import com.telepigeon.server.domain.User;
import com.telepigeon.server.dto.oauth.request.KakaoUnlinkDto;
import com.telepigeon.server.dto.auth.SocialUserInfoDto;
import com.telepigeon.server.exception.BusinessException;
import com.telepigeon.server.exception.UnAuthorizedException;
import com.telepigeon.server.exception.code.BusinessErrorCode;
import com.telepigeon.server.exception.code.UnAuthorizedErrorCode;
import com.telepigeon.server.oauth.dto.KakaoUserDto;
import com.telepigeon.server.dto.oauth.request.KakaoUserDto;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -40,12 +39,14 @@ public SocialUserInfoDto getUserInfo(final String token) {
public void unlink(final User user) {
RestClient restClient = RestClient.create();

KakaoUnlinkDto unlinkRequest = KakaoUnlinkDto.of(Long.getLong(user.getSerialId()));
restClient.post()
.uri(kakaoUnlinkUrl)
.uri(uriBuilder -> uriBuilder.path(kakaoUnlinkUrl)
.queryParam("target_id_type", "user_id")
.queryParam("target_id", Long.getLong(user.getSerialId()))
.build()
)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.header(AuthConstant.AUTHORIZATION_HEADER, "KakaoAK " + kakaoAdminKey)
.body(unlinkRequest)
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, (request, response) -> {
throw new BusinessException(BusinessErrorCode.INVALID_KAKAO_ADMIN_KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.telepigeon.server.dto.auth.SocialUserInfoDto;
import com.telepigeon.server.exception.UnAuthorizedException;
import com.telepigeon.server.exception.code.UnAuthorizedErrorCode;
import com.telepigeon.server.oauth.service.KakaoService;
import com.telepigeon.server.service.external.KakaoService;
import com.telepigeon.server.service.auth.AuthService;
import com.telepigeon.server.service.auth.TokenRemover;
import com.telepigeon.server.service.auth.TokenRetriever;
Expand Down

0 comments on commit 75b4e81

Please sign in to comment.