Skip to content

Commit

Permalink
원격 변경사항 병합 및 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
dltjdgh0428 committed Mar 28, 2024
2 parents 12fbd91 + c244e09 commit d3cc005
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@RequiredArgsConstructor
@Service
@Slf4j
public class CustomOAuth2UserService extends DefaultOAuth2UserService {
public class CustomOAuth2UserService implements OAuth2UserService<OAuth2UserRequest, OAuth2User> {

private final UserRepository userRepository;
private final HttpSession httpSession;
Expand All @@ -37,9 +37,10 @@ public class CustomOAuth2UserService extends DefaultOAuth2UserService {
* 그러면 로그인하는 사용자의 공급자 등록 ID 및 사용자 이름 속성 이름과 같은 사용자 정보를 가져와서 OAuthAttributes 객체로 변환합니다.
*/
@Override
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException{
public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException {

OAuth2User oAuth2User = super.loadUser(userRequest);
OAuth2UserService<OAuth2UserRequest, OAuth2User> delegate = new DefaultOAuth2UserService();
OAuth2User oAuth2User = delegate.loadUser(userRequest);

String registrationId = userRequest.getClientRegistration().getRegistrationId();
String userNameAttributeName = userRequest.getClientRegistration().getProviderDetails().getUserInfoEndpoint().getUserNameAttributeName();
Expand All @@ -49,7 +50,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic
User user = saveOrUpdate(attributes);
httpSession.setAttribute("user", user);

// UserDetails 객체 생성 또는 조회

UserDetails userDetails = customUserDetailsService.loadUserBySocialId(user.getSocialId());
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);
Expand Down

0 comments on commit d3cc005

Please sign in to comment.