mirror of https://gitee.com/y_project/RuoYi.git
用户修改新密码不能与旧密码相同
parent
182c377ecb
commit
aa0c930682
|
@ -16,7 +16,6 @@ import com.ruoyi.common.config.Global;
|
|||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||
import com.ruoyi.framework.shiro.service.SysPasswordService;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
|
@ -80,22 +79,26 @@ public class SysProfileController extends BaseController
|
|||
@ResponseBody
|
||||
public AjaxResult resetPwd(String oldPassword, String newPassword)
|
||||
{
|
||||
|
||||
SysUser user = ShiroUtils.getSysUser();
|
||||
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
|
||||
{
|
||||
user.setSalt(ShiroUtils.randomSalt());
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
||||
if (userService.resetUserPwd(user) > 0)
|
||||
{
|
||||
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
||||
return success();
|
||||
}
|
||||
return error();
|
||||
}
|
||||
else
|
||||
if (!passwordService.matches(user, oldPassword))
|
||||
{
|
||||
return error("修改密码失败,旧密码错误");
|
||||
}
|
||||
if (passwordService.matches(user, newPassword))
|
||||
{
|
||||
return error("新密码不能与旧密码相同");
|
||||
}
|
||||
user.setSalt(ShiroUtils.randomSalt());
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
||||
if (userService.resetUserPwd(user) > 0)
|
||||
{
|
||||
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
||||
return success();
|
||||
}
|
||||
return error("修改密码异常,请联系管理员");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue