diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/OauthRepositoryImpl.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/OauthRepositoryImpl.java index 628ef0de..aabd3de9 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/OauthRepositoryImpl.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/OauthRepositoryImpl.java @@ -10,6 +10,7 @@ import org.depromeet.spot.infrastructure.jpa.oauth.entity.KakaoTokenEntity; import org.depromeet.spot.infrastructure.jpa.oauth.entity.KakaoUserInfoEntity; import org.depromeet.spot.usecase.port.out.oauth.OauthRepository; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatusCode; import org.springframework.stereotype.Repository; @@ -25,6 +26,9 @@ @RequiredArgsConstructor public class OauthRepositoryImpl implements OauthRepository { + @Value("${aws.s3.basicProfileImageUrl}") + private String BASIC_PROFILE_IMAGE_URL; + private final String BEARER = "Bearer"; private final OauthProperties properties; @@ -138,16 +142,17 @@ public Member getKakaoRegisterUserInfo(String accessToken, Member member) { KakaoUserInfoEntity userInfo = getKakaoUserInfo(accessToken); // 회원가입 시 받은 정보를 바탕으로 member로 변환해서 리턴. - return userInfo.toKakaoDomain(member); + return userInfo.toKakaoDomain(member, BASIC_PROFILE_IMAGE_URL); } @Override public Member getOauthRegisterUserInfo(String accessToken, Member member) { switch (member.getSnsProvider()) { case KAKAO: - return getKakaoUserInfo(accessToken).toKakaoDomain(member); + return getKakaoUserInfo(accessToken).toKakaoDomain(member, BASIC_PROFILE_IMAGE_URL); default: - return getGoogleUserInfo(accessToken).toGoogleDomain(member); + return getGoogleUserInfo(accessToken) + .toGoogleDomain(member, BASIC_PROFILE_IMAGE_URL); } } diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/GoogleUserInfoEntity.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/GoogleUserInfoEntity.java index 07d2b20d..dc0454db 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/GoogleUserInfoEntity.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/GoogleUserInfoEntity.java @@ -4,7 +4,6 @@ import org.depromeet.spot.domain.member.enums.MemberRole; import org.depromeet.spot.domain.member.enums.SnsProvider; import org.depromeet.spot.infrastructure.jpa.common.entity.BaseEntity; -import org.springframework.beans.factory.annotation.Value; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,9 +16,6 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class GoogleUserInfoEntity extends BaseEntity { - @Value("${aws.s3.basicProfileImageUrl}") - private String BASIC_PROFILE_IMAGE_URL; - // 구글 로그인은 sub라는 이름으로 id값을 줌. // 구글의 sub 값은 Long 타입을 넘어감. // BigInteger로 처리하거나 String으로 처리해야함. @@ -38,11 +34,11 @@ public class GoogleUserInfoEntity extends BaseEntity { @JsonProperty("picture") public String profileImageUrl; - public Member toGoogleDomain(Member member) { + public Member toGoogleDomain(Member member, String basicProfileImageUrl) { return Member.builder() .email(email) .nickname(member.getNickname()) - .profileImage(BASIC_PROFILE_IMAGE_URL) + .profileImage(basicProfileImageUrl) .snsProvider(SnsProvider.GOOGLE) .idToken(idToken) .role(MemberRole.ROLE_USER) diff --git a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/KakaoUserInfoEntity.java b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/KakaoUserInfoEntity.java index 1708a1d1..9cb76298 100644 --- a/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/KakaoUserInfoEntity.java +++ b/infrastructure/src/main/java/org/depromeet/spot/infrastructure/jpa/oauth/entity/KakaoUserInfoEntity.java @@ -8,7 +8,6 @@ import org.depromeet.spot.domain.member.enums.MemberRole; import org.depromeet.spot.domain.member.enums.SnsProvider; import org.depromeet.spot.infrastructure.jpa.common.entity.BaseEntity; -import org.springframework.beans.factory.annotation.Value; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -16,15 +15,14 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; +import lombok.extern.slf4j.Slf4j; +@Slf4j @Getter @NoArgsConstructor // 역직렬화를 위한 기본 생성자 @JsonIgnoreProperties(ignoreUnknown = true) public class KakaoUserInfoEntity extends BaseEntity { - @Value("${aws.s3.basicProfileImageUrl}") - private String BASIC_PROFILE_IMAGE_URL; - // 서비스에 연결 완료된 시각. UTC @JsonProperty("connected_at") public Date connectedAt; @@ -98,13 +96,13 @@ public class Profile { } } - public Member toKakaoDomain(Member member) { + public Member toKakaoDomain(Member member, String basicProfileImageUrl) { return Member.builder() .email(kakaoAccount.email) .name(kakaoAccount.name) .nickname(member.getNickname()) .phoneNumber(kakaoAccount.phoneNumber) - .profileImage(BASIC_PROFILE_IMAGE_URL) + .profileImage(basicProfileImageUrl) .snsProvider(SnsProvider.KAKAO) .idToken(getId().toString()) .role(MemberRole.ROLE_USER)