mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
PasswordSetType
This commit is contained in:
parent
8210d11fa3
commit
494b2b01d0
@ -216,7 +216,8 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
|
|
||||||
public boolean changePassword( String oldPassword,
|
public boolean changePassword( String oldPassword,
|
||||||
String newPassword,
|
String newPassword,
|
||||||
String confirmPassword) {
|
String confirmPassword,
|
||||||
|
int passwordSetType) {
|
||||||
try {
|
try {
|
||||||
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, "");
|
||||||
UserInfo userInfo = WebContext.getUserInfo();
|
UserInfo userInfo = WebContext.getUserInfo();
|
||||||
@ -225,6 +226,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
|||||||
changeUserInfo.setPassword(newPassword);
|
changeUserInfo.setPassword(newPassword);
|
||||||
changeUserInfo.setId(userInfo.getId());
|
changeUserInfo.setId(userInfo.getId());
|
||||||
changeUserInfo.setDecipherable(userInfo.getDecipherable());
|
changeUserInfo.setDecipherable(userInfo.getDecipherable());
|
||||||
|
changeUserInfo.setPasswordSetType(passwordSetType);
|
||||||
|
|
||||||
if(newPassword.equals(confirmPassword)){
|
if(newPassword.equals(confirmPassword)){
|
||||||
if(oldPassword==null ||
|
if(oldPassword==null ||
|
||||||
|
|||||||
@ -98,8 +98,8 @@
|
|||||||
<if test="password != null">
|
<if test="password != null">
|
||||||
password = #{password},
|
password = #{password},
|
||||||
decipherable = #{decipherable},
|
decipherable = #{decipherable},
|
||||||
|
passwordsettype = #{passwordSetType},
|
||||||
</if>
|
</if>
|
||||||
passwordsettype = 0,
|
|
||||||
passwordlastsettime = current_timestamp
|
passwordlastsettime = current_timestamp
|
||||||
where
|
where
|
||||||
id = #{id}
|
id = #{id}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class SafeController {
|
|||||||
@RequestParam("newPassword") String newPassword,
|
@RequestParam("newPassword") String newPassword,
|
||||||
@RequestParam("confirmPassword") String confirmPassword) {
|
@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);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
||||||
}else {
|
}else {
|
||||||
return new Message(
|
return new Message(
|
||||||
@ -82,7 +82,7 @@ public class SafeController {
|
|||||||
ModelAndView modelAndView=new ModelAndView("passwordExpired");
|
ModelAndView modelAndView=new ModelAndView("passwordExpired");
|
||||||
if(newPassword ==null ||newPassword.equals("")) {
|
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);
|
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,ConstantsPasswordSetType.PASSWORD_NORMAL);
|
||||||
return WebContext.redirect("/index");
|
return WebContext.redirect("/index");
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ public class SafeController {
|
|||||||
ModelAndView modelAndView=new ModelAndView("passwordInitial");
|
ModelAndView modelAndView=new ModelAndView("passwordInitial");
|
||||||
if(newPassword ==null ||newPassword.equals("")) {
|
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);
|
WebContext.getSession().setAttribute(WebConstants.CURRENT_LOGIN_USER_PASSWORD_SET_TYPE,ConstantsPasswordSetType.PASSWORD_NORMAL);
|
||||||
return WebContext.redirect("/index");
|
return WebContext.redirect("/index");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import javax.validation.Valid;
|
|||||||
|
|
||||||
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
||||||
import org.maxkey.constants.ConstantsOperateMessage;
|
import org.maxkey.constants.ConstantsOperateMessage;
|
||||||
|
import org.maxkey.constants.ConstantsPasswordSetType;
|
||||||
import org.maxkey.crypto.ReciprocalUtils;
|
import org.maxkey.crypto.ReciprocalUtils;
|
||||||
import org.maxkey.entity.ExcelImport;
|
import org.maxkey.entity.ExcelImport;
|
||||||
import org.maxkey.entity.UserInfo;
|
import org.maxkey.entity.UserInfo;
|
||||||
@ -264,6 +265,7 @@ public class UserInfoController {
|
|||||||
@RequestMapping(value="/changePassword")
|
@RequestMapping(value="/changePassword")
|
||||||
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
|
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
|
||||||
_logger.debug(userInfo.getId());
|
_logger.debug(userInfo.getId());
|
||||||
|
userInfo.setPasswordSetType(ConstantsPasswordSetType.PASSWORD_NORMAL);
|
||||||
if(userInfoService.changePassword(userInfo,true)) {
|
if(userInfoService.changePassword(userInfo,true)) {
|
||||||
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user