diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/OAuthAttributes.java b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/OAuthAttributes.java index f3aacaa1..2dfcb75c 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/OAuthAttributes.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/OAuthAttributes.java @@ -41,7 +41,7 @@ public Member toEntity(SocialType socialType, OAuth2UserInfo oauth2UserInfo) { .email(oauth2UserInfo.getEmail()) .nickname(oauth2UserInfo.getNickname()) .imageUrl(oauth2UserInfo.getImageUrl()) - .role(Role.GUEST) + .role(Role.USER) .status(Status.ACTIVE) .build(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/service/AuthService.java b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/service/AuthService.java index 3d150356..85bcaef7 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/service/AuthService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/service/AuthService.java @@ -41,8 +41,8 @@ private Member registerMember(SocialType socialType, OAuth2UserInfo userInfo) { Member member = Member.builder() .socialType(socialType) .oauthId(userInfo.getId()) - .email(UUID.randomUUID() + "@socialUser.com") - .nickname(String.valueOf(UUID.randomUUID())) + .email(userInfo.getEmail()) + .nickname(userInfo.getNickname()) .imageUrl(userInfo.getImageUrl()) .role(Role.USER) .build(); @@ -51,10 +51,9 @@ private Member registerMember(SocialType socialType, OAuth2UserInfo userInfo) { } public Member getMember() { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - UserDetails userDetails = (UserDetails) authentication.getPrincipal(); - return memberRepository.findByEmail(userDetails.getUsername()).orElseThrow(MemberNotFoundException::new); + String username = authentication.getName(); + return memberRepository.findByEmail(username).orElseThrow(MemberNotFoundException::new); } }