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 Details

    • UserService

      public UserService(AthleteRepository athleteRepository, AdminRepository adminRepository)
      Constructs a new UserService with the required repositories.
      Parameters:
      athleteRepository - the repository for athlete data access
      adminRepository - 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:
      loadUserByUsername in interface org.springframework.security.core.userdetails.UserDetailsService
      Parameters:
      email - the email address used as the login identifier
      Returns:
      a UserDetails instance with the appropriate role and credentials
      Throws:
      org.springframework.security.core.userdetails.UsernameNotFoundException - if no user is found with the given email