}
@RequestMapping(value="/login-action", method=RequestMethod.POST)
public String doLoginAction(@Valid LoginBean loginBean, BindingResult result,
Model model, HttpSession session, HttpServletResponse response) throws Exception {
User user = userService.loginUser(loginBean.getUsername(), loginBean.getPassword());
if(result.hasErrors() || user==null) {
model.addAttribute(AttributeKeys.SHOW_ERRORS_KEY_READABLE, true);
return "page:system/login";
}
//
if(loginBean.getRememberMe()) {
String username = CipherUtil.encrypt(user.getUsername(), KEY_FILE);
Cookie cookie = new Cookie(AttributeKeys.REMEMBER_ME_KEY, username);
cookie.setPath("/connect");
response.addCookie(cookie);
}
session.setAttribute(AttributeKeys.USER_ID_KEY, user.getId());
return String.format("redirect:/%s/profile", user.getProject().getUniqueId());
}