Skip to content

Commit

Permalink
[#4] 이메일 중복되는 경우 oauthId로 분류
Browse files Browse the repository at this point in the history
  • Loading branch information
jun108059 committed Oct 7, 2021
1 parent 711d8f2 commit 05ad8f4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@Getter
public class OAuthAttributes {
private final Map<String, Object> attributes; // OAuth2 반환하는 유저 정보 Map
private final Integer oauthId;
private final String nameAttributeKey;
private final String name;
private final String email;
Expand All @@ -39,6 +40,7 @@ public static OAuthAttributes of(String provider, String userNameAttributeName,

private static OAuthAttributes ofGoogle(String userNameAttributeName, Map<String, Object> attributes) {
return OAuthAttributes.builder()
.oauthId((Integer) attributes.get("id"))
.name((String) attributes.get("name"))
.email((String) attributes.get("email"))
.picture((String) attributes.get("picture"))
Expand All @@ -55,6 +57,7 @@ private static OAuthAttributes ofKakao(Map<String, Object> attributes) {
Map<String, Object> kakaoProfile = (Map<String, Object>) kakaoAccount.get("profile");

return OAuthAttributes.builder()
.oauthId((Integer) attributes.get("id"))
.name((String) kakaoProfile.get("nickname"))
.email((String) kakaoAccount.get("email"))
.picture((String) kakaoProfile.get("profile_image_url"))
Expand All @@ -79,8 +82,11 @@ private static OAuthAttributes ofNaver(Map<String, Object> attributes) {

public Member toEntity(){
return Member.builder()
.oauthId(oauthId)
.password(null)
.name(name)
.email(email)
.nickName(null)
.picture(picture)
.role(Role.USER) // 기본 권한 GUEST, 일반 : USER
.provider(provider)
Expand Down

0 comments on commit 05ad8f4

Please sign in to comment.