ModelAndView view = new ModelAndView();
User user = userService.userValidation(userName, password);
if (user == null) {//用户不存在
view.setViewName(KeyConstant.ERROR_PAGE);
} else {
JCMSProperties propertiy = JCMSProperties.getInstance();
HttpSession session = request.getSession();
if (authCode.equals(session.getAttribute(KeyConstant.SESSION_KEY_AUTH_CODE))) {
if (BooleanUtils.isTrue(remember)) {//保存记住用户名的cookie
Cookie cookie = new Cookie(KeyConstant.COOKIE_KEY_USERNAME, userName);
cookie.setMaxAge(3600 * 24 * 7);
cookie.setPath(propertiy.getHost());
response.addCookie(cookie);
}
session.removeAttribute(KeyConstant.SESSION_KEY_AUTH_CODE);
session.setAttribute(KeyConstant.SESSION_KEY_USER, user);
view.setViewName("redirect:/admin/common/index.do");