Package com.ericbouchut.learndev.auth
Class AuthController
java.lang.Object
com.ericbouchut.learndev.auth.AuthController
Web endpoints for authentication pages:
home and login views, and the registration form
(display and submission).
The dashboard lives in the course package (it renders enrollments).
Spring Security handles the login POST and logout itself.
This controller renders the pages around them.
-
Constructor Summary
ConstructorsConstructorDescriptionAuthController(RegistrationService registration, EmailVerificationService verification) -
Method Summary
Modifier and TypeMethodDescriptionhome()GET / Display the home page.login()Display the login form.register(@Valid RegisterForm form, org.springframework.validation.BindingResult binding, jakarta.servlet.http.HttpServletRequest request) Processes a submitted registration form.registerForm(org.springframework.ui.Model model) Display the User registration form.
-
Constructor Details
-
AuthController
-
-
Method Details
-
home
GET / Display the home page.- Returns:
- the name of the Thymeleaf template (aka. View name) for the home page The View will read and render this template.
-
login
Display the login form.- Returns:
- the name of the login template
-
registerForm
Display the User registration form.- Parameters:
model-- Returns:
- the key of the registration Thymeleaf template
-
register
@PostMapping("/auth/register") public String register(@Valid @ModelAttribute("form") @Valid RegisterForm form, org.springframework.validation.BindingResult binding, jakarta.servlet.http.HttpServletRequest request) Processes a submitted registration form. Bean-validation failures and duplicate username/email are turned into field errors so the form is re-rendered with the user's input. A successful registration redirects to the login page with anregisteredURL query parameter.- Parameters:
form- the submitted form, validated by@Validbinding- collects validation and duplicate-field errors- Returns:
- the view name to render, or a redirect on success
-