Class AuthController

java.lang.Object
fr.utc.miage.sporttrack.controller.AuthController

@Controller @RequestMapping("/") public class AuthController extends Object
Spring MVC controller that handles user authentication flows including login and registration.
Author:
SportTrack Team
  • Constructor Details

    • AuthController

      public AuthController(AthleteService athleteService)
      Constructs an AuthController with the required service.
      Parameters:
      athleteService - the athlete service for profile creation
  • Method Details

    • login

      @GetMapping("/login") public String login()
      Displays the login form.
      Returns:
      the view name "login"
    • showRegistrationForm

      @GetMapping("/register") public String showRegistrationForm(org.springframework.ui.Model model)
      Displays the athlete registration form.
      Parameters:
      model - the Spring MVC model for view rendering
      Returns:
      the view name "register"
    • registerUser

      @PostMapping("/register") public String registerUser(@ModelAttribute("registerForm") AthleteRegisterFormDTO athleteDto, @RequestParam(value="email",required=false) String email, @RequestParam(value="username",required=false) String username, @RequestParam(value="password",required=false) String password, @RequestParam(value="confirmPassword",required=false) String confirmPassword, org.springframework.ui.Model model)
      Processes the registration form submission. Validates that the password and confirmation match before delegating to the athlete service.
      Parameters:
      athleteDto - the registration form data bound from the request
      confirmPassword - the confirmed password entered by the user
      model - the Spring MVC model for error rendering
      Returns:
      a redirect to the login page on success, or the register view on error