This commit is contained in:
Viktoria committed 2022-08-29 16:33:31 +02:00
1 parent 0395ab2195
commit 43508ff6c4
6 files changed
+111 -21

No files matched your search

@@ -2,6 +2,7 @@ package site.easystartup.web.service;
import lombok.RequiredArgsConstructor;
import org.hibernate.query.criteria.internal.predicate.PredicateImplementor;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import site.easystartup.web.domain.User;
import site.easystartup.web.repo.UserRepo;
@@ -16,4 +17,8 @@ public class UserService {
public User getUserByPrincipal(Principal principal) {
return userRepo.findByUsername(principal.getName());
}
public User getUserById(Long userId) {
return userRepo.findById(userId).orElseThrow(() -> new UsernameNotFoundException("User not found"));
}
}