Class UserService
java.lang.Object
fr.utc.miage.sporttrack.service.user.UserService
- All Implemented Interfaces:
org.springframework.security.core.userdetails.UserDetailsService
@Service
public class UserService
extends Object
implements org.springframework.security.core.userdetails.UserDetailsService
Service layer component implementing Spring Security's
UserDetailsService
for the SportTrack application.
This service resolves login credentials by looking up athletes first, then
administrators, using the email address as the principal username. It constructs
a UserDetails object with the appropriate role ("USER" or "ADMIN").
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionUserService(AthleteRepository athleteRepository, AdminRepository adminRepository) Constructs a newUserServicewith the required repositories. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.userdetails.UserDetailsloadUserByUsername(String email) Loads a user by their email address, searching athletes first then admins.
-
Constructor Details
-
UserService
Constructs a newUserServicewith the required repositories.- Parameters:
athleteRepository- the repository for athlete data accessadminRepository- the repository for admin data access
-
-
Method Details
-
loadUserByUsername
public org.springframework.security.core.userdetails.UserDetails loadUserByUsername(String email) throws org.springframework.security.core.userdetails.UsernameNotFoundException Loads a user by their email address, searching athletes first then admins.- Specified by:
loadUserByUsernamein interfaceorg.springframework.security.core.userdetails.UserDetailsService- Parameters:
email- the email address used as the login identifier- Returns:
- a
UserDetailsinstance with the appropriate role and credentials - Throws:
org.springframework.security.core.userdetails.UsernameNotFoundException- if no user is found with the given email
-