|
@@ -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))
|
|
|
+ if (!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();
|
|
|
+ return error("修改密码失败,旧密码错误");
|
|
|
}
|
|
|
- else
|
|
|
+ if (passwordService.matches(user, newPassword))
|
|
|
{
|
|
|
- return error("修改密码失败,旧密码错误");
|
|
|
+ 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("修改密码异常,请联系管理员");
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|