Class AuthController

java.lang.Object
com.ericbouchut.learndev.auth.AuthController

@Controller public class AuthController extends Object
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 Details

  • Method Details

    • home

      @GetMapping("/") public String 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

      @GetMapping("/auth/login") public String login()
      Display the login form.
      Returns:
      the name of the login template
    • registerForm

      @GetMapping("/auth/register") public String registerForm(org.springframework.ui.Model model)
      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 an registered URL query parameter.
      Parameters:
      form - the submitted form, validated by @Valid
      binding - collects validation and duplicate-field errors
      Returns:
      the view name to render, or a redirect on success