Class AuthController
java.lang.Object
fr.utc.miage.sporttrack.controller.AuthController
Spring MVC controller that handles user authentication flows
including login and registration.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionAuthController(AthleteService athleteService) Constructs anAuthControllerwith the required service. -
Method Summary
Modifier and TypeMethodDescriptionlogin()Displays the login form.registerUser(AthleteRegisterFormDTO athleteDto, String email, String username, String password, String confirmPassword, org.springframework.ui.Model model) Processes the registration form submission.showRegistrationForm(org.springframework.ui.Model model) Displays the athlete registration form.
-
Constructor Details
-
AuthController
Constructs anAuthControllerwith the required service.- Parameters:
athleteService- the athlete service for profile creation
-
-
Method Details
-
login
Displays the login form.- Returns:
- the view name "login"
-
showRegistrationForm
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 requestconfirmPassword- the confirmed password entered by the usermodel- the Spring MVC model for error rendering- Returns:
- a redirect to the login page on success, or the register view on error
-