Skip to content

Commit

Permalink
modified exception type
Browse files Browse the repository at this point in the history
  • Loading branch information
Optic-Okulist committed Sep 28, 2023
1 parent 6f986c2 commit ffc333f
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.stereotype.Component;
import spring.boot.bookstore.dto.user.UserRegistrationRequestDto;
import spring.boot.bookstore.dto.user.UserResponseDto;
import spring.boot.bookstore.exception.EntityNotFoundException;
import spring.boot.bookstore.exception.RegistrationException;
import spring.boot.bookstore.mapper.UserMapper;
import spring.boot.bookstore.model.Role;
Expand All @@ -20,7 +21,6 @@
@RequiredArgsConstructor
@Component
public class UserServiceImpl implements UserService {

private final PasswordEncoder passwordEncoder;
private final UserRepository userRepository;
private final UserMapper userMapper;
Expand Down Expand Up @@ -51,8 +51,7 @@ public UserResponseDto register(UserRegistrationRequestDto request)
public User getAuthenticated() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
return userRepository.findByEmail(authentication.getName()).orElseThrow(
() -> new RuntimeException("Can`t find user with according email"
() -> new EntityNotFoundException("Can`t find user with according email"
+ authentication.getName()));
}
}

0 comments on commit ffc333f

Please sign in to comment.