|
@@ -24,7 +24,7 @@ import java.util.Arrays;
|
|
|
|
|
|
/**
|
|
|
* 个人信息 业务处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
*/
|
|
|
@RestController
|
|
@@ -33,10 +33,10 @@ public class SysProfileController extends BaseController
|
|
|
{
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private RemoteFileService remoteFileService;
|
|
|
|
|
@@ -123,7 +123,36 @@ public class SysProfileController extends BaseController
|
|
|
}
|
|
|
return AjaxResult.error("修改密码异常,请联系管理员");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @PostMapping("/updateLrPwd")
|
|
|
+ public AjaxResult updateLrPwd(String oldPassword, String newPassword)
|
|
|
+ {
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
+ SysUser user = userService.selectLrUserByUserName(username);
|
|
|
+ String password = user.getPassword();
|
|
|
+ if (!SecurityUtils.matchesPassword(oldPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("修改密码失败,旧密码错误");
|
|
|
+ }
|
|
|
+ if (SecurityUtils.matchesPassword(newPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("新密码不能与旧密码相同");
|
|
|
+ }
|
|
|
+ if (!SecurityUtils.checkPassword(newPassword))
|
|
|
+ {
|
|
|
+ return AjaxResult.error("密码最少包含数字丶字母丶特殊字符中的两种");
|
|
|
+ }
|
|
|
+ if (userService.resetLrUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0)
|
|
|
+ {
|
|
|
+ // 更新缓存用户密码
|
|
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
+ loginUser.getSysUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
|
|
+ tokenService.setLoginUser(loginUser);
|
|
|
+ return AjaxResult.success("密码修改成功");
|
|
|
+ }
|
|
|
+ return AjaxResult.error("修改密码异常,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 头像上传
|
|
|
*/
|