Skip to content

Commit

Permalink
[refactor] OAuthService log
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeesw committed Sep 15, 2024
1 parent 1f21f37 commit 72de4a0
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@ public class OAuthService {
// 소셜 로그인
@Transactional
public LoginSuccessResponseDto oAuthLogin(Provider provider, String idToken, Boolean isCustom) { // isCustom: 개발용
log.trace("OAuthService > oAuthLogin()");
log.trace("OAuthService > oAuthLogin() !!");

if (idToken == null || idToken.isEmpty()){
throw new CustomException(ErrorCode.ID_TOKEN_IS_NULL);
}

String providerId = oidcProviderFactory.getProviderId(provider, idToken);
log.trace("???? 46");

// kakaoId로 유저 조회
User user = userService.findByUsername(providerId);
Boolean isNewUser = Boolean.FALSE;

log.trace("???? 52");

// 조회된 유저가 없을 시 회원가입 처리
if (user == null) {
isNewUser = Boolean.TRUE;
Expand All @@ -65,6 +68,8 @@ public LoginSuccessResponseDto oAuthLogin(Provider provider, String idToken, Boo

userRepository.save(user);

log.trace("???? 71");

// UserDetailsService를 사용하여 UserDetails 객체 생성
UserDetails userDetails = userDetailsService.loadUserByUsername(providerId);

Expand All @@ -76,10 +81,14 @@ public LoginSuccessResponseDto oAuthLogin(Provider provider, String idToken, Boo
jwtTokenDto = jwtUtil.generateToken(userDetails);
}

log.trace("???? 84");

// 사용자 인증 정보 생성 및 SecurityContext에 저장
Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authentication);

log.trace("???? 90");

// Redis에 RefreshToken 저장
jwtUtil.storeRefreshTokenInRedis(authentication, jwtTokenDto.getRefreshToken());

Expand Down

0 comments on commit 72de4a0

Please sign in to comment.