Skip to content

Commit

Permalink
Fix: 회원탈퇴 api 수정 (#64)
Browse files Browse the repository at this point in the history
카카오 연결 끊기 추가

#63
  • Loading branch information
wcorn authored Jan 2, 2024
1 parent 82fc96e commit 43be2a2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fubao-server-secret
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void deactivation(UUID memberId) {
Post::delete
);
member.deactivation();
requestOAuthInfoService.disconnect(member.getOauthProvider(),member.getProviderId());
}

private Member findById(UUID memberId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ public OAuthInfoResponse request(OAuthLoginParams params) {
String accessToken = client.requestAccessToken(params);
return client.requestOAuthInfo(accessToken);
}

public void disconnect(OAuthProvider provider, String providerId) {
OAuthApiClient client = clients.get(provider);
client.disconnect(providerId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class KakaoApiClient implements OAuthApiClient {

@Value("${oauth.kakao.client-id}")
private String clientId;

@Value("${oauth.kakao.admin-key}")
private String adminKey;
private final RestTemplate restTemplate;

@Override
Expand Down Expand Up @@ -76,4 +77,17 @@ public OAuthInfoResponse requestOAuthInfo(String accessToken) {

return restTemplate.postForObject(url, request, KakaoInfoResponse.class);
}

@Override
public void disconnect(String providerId) {
String url = apiUrl + "/v1/user/unlink";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
httpHeaders.set("Authorization", "KakaoAK " + adminKey);
MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
body.add("target_id_type", "user_id");
body.add("target_id", providerId);
HttpEntity<?> request = new HttpEntity<>(body, httpHeaders);
restTemplate.exchange(url, HttpMethod.POST, request, String.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ public interface OAuthApiClient {
OAuthProvider oAuthProvider();
String requestAccessToken(OAuthLoginParams params);
OAuthInfoResponse requestOAuthInfo(String accessToken);

void disconnect(String providerId);
}

0 comments on commit 43be2a2

Please sign in to comment.