diff --git a/maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java b/maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java index 0419aafda77966c80423a15c83785e5a19810acc..fc3f58f1c681ea3ebeb0de911551fae03e81e4b1 100644 --- a/maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java +++ b/maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java @@ -214,9 +214,10 @@ public class UserInfoService extends JpaBaseService { } - public boolean changePassword(String oldPassword, - String newPassword, - String confirmPassword) { + public boolean changePassword( String oldPassword, + String newPassword, + String confirmPassword, + int passwordSetType) { try { WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, ""); UserInfo userInfo = WebContext.getUserInfo(); @@ -225,6 +226,7 @@ public class UserInfoService extends JpaBaseService { changeUserInfo.setPassword(newPassword); changeUserInfo.setId(userInfo.getId()); changeUserInfo.setDecipherable(userInfo.getDecipherable()); + changeUserInfo.setPasswordSetType(passwordSetType); if(newPassword.equals(confirmPassword)){ if(oldPassword==null || diff --git a/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/UserInfoMapper.xml b/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/UserInfoMapper.xml index d0750f812bd1bf2bf1a89023de3f3d28dc0dad17..631b8cbf49e8e3c09c45aa77a8ad44b84073bfe3 100644 --- a/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/UserInfoMapper.xml +++ b/maxkey-persistence/src/main/resources/org/maxkey/persistence/mapper/xml/mysql/UserInfoMapper.xml @@ -95,12 +95,12 @@ update mxk_userinfo set - - password = #{password}, - decipherable = #{decipherable}, - - passwordsettype = 0, - passwordlastsettime = current_timestamp + + password = #{password}, + decipherable = #{decipherable}, + passwordsettype = #{passwordSetType}, + + passwordlastsettime = current_timestamp where id = #{id} diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/SafeController.java b/maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/SafeController.java index 00e44a6710394ebf5cce273cf0e0018a5c41fbb9..002ec86932b3496a686fd6a458a372a17399a766 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/SafeController.java +++ b/maxkey-webs/maxkey-web-maxkey/src/main/java/org/maxkey/web/contorller/SafeController.java @@ -64,7 +64,7 @@ public class SafeController { @RequestParam("newPassword") String newPassword, @RequestParam("confirmPassword") String confirmPassword) { - if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword)) { + if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword,ConstantsPasswordSetType.PASSWORD_NORMAL)) { return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success); }else { return new Message( @@ -82,7 +82,7 @@ public class SafeController { ModelAndView modelAndView=new ModelAndView("passwordExpired"); if(newPassword ==null ||newPassword.equals("")) { - }else if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword)){ + }else if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword,ConstantsPasswordSetType.PASSWORD_NORMAL)){ WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,ConstantsPasswordSetType.PASSWORD_NORMAL); return WebContext.redirect("/index"); } @@ -103,7 +103,7 @@ public class SafeController { ModelAndView modelAndView=new ModelAndView("passwordInitial"); if(newPassword ==null ||newPassword.equals("")) { - }else if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword)){ + }else if(userInfoService.changePassword(oldPassword,newPassword,confirmPassword,ConstantsPasswordSetType.PASSWORD_NORMAL)){ WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,ConstantsPasswordSetType.PASSWORD_NORMAL); return WebContext.redirect("/index"); } diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java index 7fe6da58111c82f7255d49d5b488ed8a2ce4b6b6..2612c9cfe06e7690af57a72664c66e8776c20cc2 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java +++ b/maxkey-webs/maxkey-web-mgt/src/main/java/org/maxkey/web/contorller/UserInfoController.java @@ -27,6 +27,7 @@ import javax.validation.Valid; import org.apache.mybatis.jpa.persistence.JpaPageResults; import org.maxkey.constants.ConstantsOperateMessage; +import org.maxkey.constants.ConstantsPasswordSetType; import org.maxkey.crypto.ReciprocalUtils; import org.maxkey.entity.ExcelImport; import org.maxkey.entity.UserInfo; @@ -264,6 +265,7 @@ public class UserInfoController { @RequestMapping(value="/changePassword") public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) { _logger.debug(userInfo.getId()); + userInfo.setPasswordSetType(ConstantsPasswordSetType.PASSWORD_NORMAL); if(userInfoService.changePassword(userInfo,true)) { return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);