66import com .example .ai_tutor .global .config .security .token .UserPrincipal ;
77import jakarta .transaction .Transactional ;
88import lombok .RequiredArgsConstructor ;
9+ import lombok .extern .slf4j .Slf4j ;
910import org .springframework .security .core .userdetails .UserDetails ;
1011import org .springframework .security .core .userdetails .UserDetailsService ;
1112import org .springframework .security .core .userdetails .UsernameNotFoundException ;
1213import org .springframework .stereotype .Service ;
1314
1415import java .util .Optional ;
1516
17+ @ Slf4j
1618@ RequiredArgsConstructor
1719@ Service
1820public class CustomUserDetailsService implements UserDetailsService {
@@ -21,21 +23,21 @@ public class CustomUserDetailsService implements UserDetailsService {
2123
2224 @ Override
2325 public UserDetails loadUserByUsername (String email ) throws UsernameNotFoundException {
24-
26+ log . debug ( "Trying to load user by email: {}" , email );
2527 User user = userRepository .findByEmail (email )
26- .orElseThrow (() ->
27- new UsernameNotFoundException ("유저 정보를 찾을 수 없습니다." )
28- );
28+ .orElseThrow (() -> new UsernameNotFoundException ("유저 정보를 찾을 수 없습니다." ));
2929
30+ log .debug ("User found: {}" , user );
3031 return UserPrincipal .create (user );
3132 }
3233
3334 @ Transactional
3435 public UserDetails loadUserById (Long id ) {
36+ log .debug ("Trying to load user by ID: {}" , id );
3537 Optional <User > user = userRepository .findById (id );
3638 DefaultAssert .isOptionalPresent (user );
3739
40+ log .debug ("User found by ID: {}" , user );
3841 return UserPrincipal .create (user .get ());
3942 }
40-
41- }
43+ }
0 commit comments