Skip to content

Commit

Permalink
fix: user 정보 모두 받기
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjy committed Jun 17, 2024
1 parent c61f0bd commit de9d356
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

}

0 comments on commit de9d356

Please sign in to comment.