merge user services
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-07 23:03:31 +02:00
parent 4c79d502e3
commit 9eea30b23e
4 changed files with 14 additions and 33 deletions

View File

@@ -1,6 +1,7 @@
package wtf.beatrice.releasehive.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import wtf.beatrice.releasehive.models.User;
import wtf.beatrice.releasehive.repositories.UserRepository;
@@ -20,4 +21,11 @@ public class UserService
return userRepository.findAll();
}
public User loadUserByUsername(String username) throws UsernameNotFoundException {
return userRepository.findByUsername(username).orElseThrow(() -> new UsernameNotFoundException(username));
}
public User loadUserByEmail(String email) throws UsernameNotFoundException {
return userRepository.findByEmail(email).orElseThrow(() -> new UsernameNotFoundException(email));
}
}