@RequestMapping(value = "/main_page") public String mainPage(Model model) { if (!userService.isAuth()) { model.addAttribute("message", "Access denied.\n"); return "login"; } return "main_page"; }
@RequestMapping(value = "/login", method = RequestMethod.POST) public String processLoginForm(Model model, @ModelAttribute("loginForm") LoginForm loginForm) { if (formProcessor.checkLoginForm(model, loginForm)) { userService.setAuth(); return "redirect:/main_page"; } else { return "login"; } }
@RequestMapping(value = "/logout") public String logout(Model model) { if (userService.isAuth()) userService.unsetAuth(); return "redirect:/"; }