diff --git a/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java b/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java index a654e10..1bbf65d 100644 --- a/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java +++ b/src/main/java/com/fullcar/member/application/auth/KakaoAuthService.java @@ -11,7 +11,6 @@ import com.fullcar.member.domain.member.Member; import com.fullcar.member.domain.member.service.MemberIdService; import com.fullcar.member.domain.member.MemberRepository; -import com.fullcar.member.presentation.auth.dto.KakaoInfoDto; import com.fullcar.member.presentation.auth.dto.request.AuthRequestDto; import com.fullcar.member.presentation.auth.dto.response.SocialInfoResponseDto; import lombok.RequiredArgsConstructor; @@ -42,12 +41,11 @@ public class KakaoAuthService implements AuthService { @Transactional public SocialInfoResponseDto getMemberInfo(AuthRequestDto authRequestDto) { String deviceToken = authRequestDto.getDeviceToken(); - KakaoInfoDto kakaoInfoDto = getKakaoData(authRequestDto.getToken()); - SocialId socialId = socialIdService.generateSocialId(kakaoInfoDto.getSocialId()); + SocialId socialId = socialIdService.generateSocialId(getKakaoData(authRequestDto.getToken())); String refreshToken = jwtTokenProvider.generateRefreshToken(); if (memberRepository.existsBySocialId(socialId)) memberRepository.findBySocialIdAndIsDeleted(socialId, false).loginMember(deviceToken, refreshToken); - else createMember(kakaoInfoDto, deviceToken, refreshToken); + else createMember(socialId, deviceToken, refreshToken); return SocialInfoResponseDto.builder() .socialId(socialId) @@ -55,7 +53,7 @@ public SocialInfoResponseDto getMemberInfo(AuthRequestDto authRequestDto) { .build(); } - private static KakaoInfoDto getKakaoData(String kakaoToken) { + private static String getKakaoData(String kakaoToken) { try { HttpHeaders headers = new HttpHeaders(); @@ -77,13 +75,8 @@ private static KakaoInfoDto getKakaoData(String kakaoToken) { ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(responseBody); - JsonNode kakaoAccount = jsonNode.get("kakao_account"); - String socialId = jsonNode.get("id").asText(); - String gender = kakaoAccount.get("gender").asText(); - String ageRange = kakaoAccount.get("age_range").asText(); - - return new KakaoInfoDto(socialId, gender, ageRange); + return jsonNode.get("id").asText(); } catch (HttpClientErrorException e) { throw new NotFoundException(ErrorCode.UNAUTHORIZED_KAKAO_TOKEN); } catch (JsonProcessingException e) { @@ -92,12 +85,10 @@ private static KakaoInfoDto getKakaoData(String kakaoToken) { } // 새로운 멤버 생성 - private void createMember(KakaoInfoDto kakaoInfoDto, String deviceToken, String refreshToken) { + private void createMember(SocialId socialId, String deviceToken, String refreshToken) { memberRepository.save(Member.builder() .id(memberIdService.nextId()) - .socialId(socialIdService.generateSocialId(kakaoInfoDto.getSocialId())) - .gender(kakaoInfoDto.getGender()) - .ageRange(kakaoInfoDto.getAgeRange()) + .socialId(socialId) .deviceToken(deviceToken) .refreshToken(refreshToken) .build()); diff --git a/src/main/java/com/fullcar/member/domain/member/Member.java b/src/main/java/com/fullcar/member/domain/member/Member.java index dca7d02..7b2781e 100644 --- a/src/main/java/com/fullcar/member/domain/member/Member.java +++ b/src/main/java/com/fullcar/member/domain/member/Member.java @@ -41,10 +41,8 @@ public class Member { private String nickname; private String email; - - private String gender; - private String ageRange; + private String gender; @Builder.Default @Column(name = "onboarding_flag") diff --git a/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java b/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java deleted file mode 100644 index eb84aea..0000000 --- a/src/main/java/com/fullcar/member/presentation/auth/dto/KakaoInfoDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fullcar.member.presentation.auth.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class KakaoInfoDto { - private String socialId; - - private String gender; - - private String ageRange; -}