patch fin projet v1

This commit is contained in:
jleroy
2024-05-02 11:57:42 +02:00
parent 8788aecb39
commit 53d7fe5a80
21 changed files with 2226 additions and 40 deletions

View File

@@ -19,10 +19,8 @@ public class LoginService implements UserDetailsService {
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// Charger l'utilisateur depuis la base de données
UserProfil utilisateur = this.userRep.findByUsername(username);
UserDetails userDetails = null;
// Créer un nouvel objet UserBuilder
if (utilisateur != null) {
userDetails = User.builder()
.username(utilisateur.getPseudo())
@@ -30,9 +28,9 @@ public class LoginService implements UserDetailsService {
.roles(utilisateur.isAdmin() ? "ADMIN" : "MEMBRE")
.build();
} else {
throw new UsernameNotFoundException("Les identifiants sont incorrect !");
throw new UsernameNotFoundException("Les identifiants sont incorrects !");
}
return userDetails;
}
}
}