Skip to content

Commit

Permalink
[NO_JIRA] login fix (#179)
Browse files Browse the repository at this point in the history
* fix : 기본 프로필 이미지 값 주입 변경(userInfoEntity는 빈이 아니라서 주입이 안됨)

* fix : 멀티스레드 리뷰 공감 Test에 문제 없도록 수정

* fix : 기본 프로필 이미지 url 값 추가
  • Loading branch information
wjdwnsdnjs13 authored Aug 29, 2024
1 parent f3484e6 commit 94033c0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ protected void doFilterInternal(
}

private boolean checkMethodWhitelist(String requestURI, String requestMethod) {
log.info("requestURI: {}", requestURI);
log.info("requestMethod: {}", requestMethod);
if (Arrays.stream(AUTH_WHITELIST).anyMatch(requestURI::startsWith)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "aws.s3")
public record ObjectStorageProperties(String accessKey, String secretKey, String bucketName) {}
public record ObjectStorageProperties(
String accessKey, String secretKey, String bucketName, String basicProfileImageUrl) {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.depromeet.spot.common.exception.oauth.OauthException.InvalidAcessTokenException;
import org.depromeet.spot.domain.member.Member;
import org.depromeet.spot.domain.member.enums.SnsProvider;
import org.depromeet.spot.infrastructure.aws.property.ObjectStorageProperties;
import org.depromeet.spot.infrastructure.jpa.oauth.config.OauthProperties;
import org.depromeet.spot.infrastructure.jpa.oauth.entity.GoogleTokenEntity;
import org.depromeet.spot.infrastructure.jpa.oauth.entity.GoogleUserInfoEntity;
Expand All @@ -28,6 +29,8 @@ public class OauthRepositoryImpl implements OauthRepository {
private final String BEARER = "Bearer";
private final OauthProperties properties;

private final ObjectStorageProperties objectStorageProperties;

private final String AUTHORIZATION_CODE = "authorization_code";

@Override
Expand Down Expand Up @@ -136,18 +139,21 @@ public String getOauthAccessToken(SnsProvider snsProvider, String authorizationC
@Override
public Member getKakaoRegisterUserInfo(String accessToken, Member member) {
KakaoUserInfoEntity userInfo = getKakaoUserInfo(accessToken);
log.info("basicProfileImage : {}", objectStorageProperties.basicProfileImageUrl());

// 회원가입 시 받은 정보를 바탕으로 member로 변환해서 리턴.
return userInfo.toKakaoDomain(member);
return userInfo.toKakaoDomain(member, objectStorageProperties.basicProfileImageUrl());
}

@Override
public Member getOauthRegisterUserInfo(String accessToken, Member member) {
switch (member.getSnsProvider()) {
case KAKAO:
return getKakaoUserInfo(accessToken).toKakaoDomain(member);
return getKakaoUserInfo(accessToken)
.toKakaoDomain(member, objectStorageProperties.basicProfileImageUrl());
default:
return getGoogleUserInfo(accessToken).toGoogleDomain(member);
return getGoogleUserInfo(accessToken)
.toGoogleDomain(member, objectStorageProperties.basicProfileImageUrl());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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으로 처리해야함.
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@
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;

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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class PresignedUrlGeneratorTest {
@BeforeEach
void init() {
ObjectStorageProperties objectStorageProperties =
new ObjectStorageProperties("accessKey", "secretKey", "bucketName");
new ObjectStorageProperties(
"accessKey", "secretKey", "bucketName", "basicProfileImageUrl");
FakeAmazonS3Config amazonS3 = new FakeAmazonS3Config(objectStorageProperties);

FakeTimeUsecase fakeTimeUsecase = new FakeTimeUsecase("2024-07-09 21:00:00");
Expand Down

0 comments on commit 94033c0

Please sign in to comment.