@RequestMapping("user-status-initPassword") public String initPassword( @RequestParam("newPassword") String newPassword, @RequestParam("confirmPassword") String confirmPassword, @RequestParam("id") Long id, RedirectAttributes redirectAttributes) { if ((newPassword != null) && newPassword.equals(confirmPassword)) { UserStatus userStatus = userStatusManager.get(id); userStatus.setPassword(newPassword); userStatusManager.save(userStatus); } messageHelper.addFlashMessage(redirectAttributes, "core.success.save", "操作成功"); return "redirect:/auth/user-status-password.do"; }
@RequestMapping("user-status-save") public String save( @ModelAttribute UserStatus userStatus, @RequestParam("confirmPassword") String confirmPassword, RedirectAttributes redirectAttributes) { try { userStatusChecker.check(userStatus); if (userStatus.getPassword() != null) { if (!userStatus.getPassword().equals(confirmPassword)) { messageHelper.addFlashMessage( redirectAttributes, "user.user.input.passwordnotequals", "两次输入密码不符"); return "auth/user-status-input"; } if (customPasswordEncoder != null) { userStatus.setPassword(customPasswordEncoder.encode(userStatus.getPassword())); } } UserStatus dest = null; Long id = userStatus.getId(); if (id != null) { dest = userStatusManager.get(id); beanMapper.copy(userStatus, dest); } else { dest = userStatus; } if (id == null) { dest.setUserRepoRef(ScopeHolder.getUserRepoRef()); dest.setScopeId(ScopeHolder.getScopeId()); } userStatusManager.save(dest); messageHelper.addFlashMessage(redirectAttributes, "core.success.save", "保存成功"); } catch (CheckUserStatusException ex) { logger.warn(ex.getMessage(), ex); messageHelper.addFlashMessage(redirectAttributes, ex.getMessage()); return "auth/user-status-input"; } return "redirect:/auth/user-status-list.do"; }