Skip to content

Commit 9572210

Browse files
committed
refactor: 유저 정보 갱신 수정
1 parent 955d4c0 commit 9572210

File tree

1 file changed

+19
-4
lines changed
  • src/main/java/com/example/log4u/domain/user/entity

1 file changed

+19
-4
lines changed

src/main/java/com/example/log4u/domain/user/entity/User.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,26 @@ public class User extends BaseEntity {
5959
@Builder.Default
6060
private boolean isPremium = false;
6161

62+
private boolean isValid(String value) {
63+
return value != null && !value.trim().isEmpty();
64+
}
65+
6266
public void updateOauth2Profile(OAuth2Response oAuth2Response) {
63-
this.email = oAuth2Response.getEmail();
64-
this.name = oAuth2Response.getName();
65-
this.nickname = oAuth2Response.getNickname();
66-
this.profileImage = oAuth2Response.getProfileImage();
67+
if (!isValid(this.email) && isValid(oAuth2Response.getEmail())) {
68+
this.email = oAuth2Response.getEmail();
69+
}
70+
71+
if (!isValid(this.name) && isValid(oAuth2Response.getName())) {
72+
this.name = oAuth2Response.getName();
73+
}
74+
75+
if (!isValid(this.nickname) && isValid(oAuth2Response.getNickname())) {
76+
this.nickname = oAuth2Response.getNickname();
77+
}
78+
79+
if (!isValid(this.profileImage) && isValid(oAuth2Response.getProfileImage())) {
80+
this.profileImage = oAuth2Response.getProfileImage();
81+
}
6782
}
6883

6984
public void updateMyProfile(UserProfileUpdateRequestDto userProfileUpdateRequestDto) {

0 commit comments

Comments
 (0)