@RequestMapping(value = "/logout", method = RequestMethod.GET) public View logout(HttpServletRequest request) { forumSession.setCurrentUser(SessionData.UNREGISTERED_USER); forumSession.setLoginRedirectURL(""); return new RedirectView(request.getHeader("Referer")); }
@RequestMapping(value = "/submitLogin", method = RequestMethod.POST) public View submitLogin( @Valid LoginForm loginForm, BindingResult bindingResult, HttpServletRequest request) { forumSession.setLoginForm(null); if (!request.getScheme().equals("https")) { throw new HttpReturnCode404NotFound(); } if (!bindingResult.hasErrors()) { User user = getUser(loginForm); if (user.isRegistered()) { forumSession.setCurrentUser(user); if (loginForm.isFromLoginPage()) { return new RedirectView(forumSession.getLoginRedirectURL()); } else { return new RedirectView(request.getHeader("Referer")); } } } if (!loginForm.isFromLoginPage()) { forumSession.setLoginRedirectURL(request.getHeader("Referer")); } loginForm.setPassword(null); forumSession.setLoginForm(loginForm); return new RedirectView("/login", true); }
@RequestMapping(value = "/login", method = RequestMethod.GET) public String login(Model model) { LoginForm loginForm = forumSession.getLoginForm(); if (loginForm == null) loginForm = new LoginForm(); model.addAttribute("loginForm", loginForm); return "th/loginPage"; }
@RequestMapping(value = "/submitsignup", method = RequestMethod.POST) public View submitSignup(@Valid SignupForm signupForm) { User newUser = new User(); newUser.setUsername(signupForm.getUsername()); newUser.setPassword(signupForm.getPassword()); newUser.setRole(permissions.getStartingRole()); userRepository.save(newUser); forumSession.setCurrentUser(newUser); return new RedirectView("/", true); }