implement registration validity checks
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-09 04:56:54 +02:00
parent c0f655b0df
commit 17dcc0ac4f
9 changed files with 108 additions and 27 deletions

View File

@@ -1,31 +1,15 @@
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;
import java.util.List;
@Service
public class UserService
public interface UserService
{
private final UserRepository userRepository;
List<User> getAllUsers();
public UserService(@Autowired UserRepository userRepository) {
this.userRepository = userRepository;
}
User loadUserByUsername(String username) throws UsernameNotFoundException;
public List<User> getAllUsers() {
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));
}
User loadUserByEmail(String email) throws UsernameNotFoundException;
}