Skip to content

Commit

Permalink
[fix] : Optional 반환값 예외처리
Browse files Browse the repository at this point in the history
  • Loading branch information
evergreenn committed Feb 22, 2024
1 parent 8be299d commit c198c2f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cona.KUsukKusuk.global.security;

import com.cona.KUsukKusuk.user.domain.User;
import com.cona.KUsukKusuk.user.exception.UserNotFoundException;
import com.cona.KUsukKusuk.user.repository.UserRepository;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
Expand All @@ -19,13 +20,13 @@ public CustomUserDetailsService(UserRepository userRepository) {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

User user = userRepository.findByUserId(username);
User user = userRepository.findByUserId(username)
.orElseThrow(()-> new UserNotFoundException());

if (user != null) {

return new CustomUserDetails(user);
}

return null;
return new CustomUserDetails(user);


}
}

0 comments on commit c198c2f

Please sign in to comment.