|
|
@@ -1,6 +1,7 @@
|
|
1
|
1
|
package com.ruoyi.system.controller;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.Arrays;
|
|
|
4
|
+import java.util.Map;
|
|
4
|
5
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
5
|
6
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
6
|
7
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -93,11 +94,13 @@ public class SysProfileController extends BaseController
|
|
93
|
94
|
*/
|
|
94
|
95
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
|
95
|
96
|
@PutMapping("/updatePwd")
|
|
96
|
|
- public AjaxResult updatePwd(String oldPassword, String newPassword)
|
|
|
97
|
+ public AjaxResult updatePwd(@RequestBody Map<String, String> params)
|
|
97
|
98
|
{
|
|
98
|
|
- String username = SecurityUtils.getUsername();
|
|
99
|
|
- SysUser user = userService.selectUserByUserName(username);
|
|
100
|
|
- String password = user.getPassword();
|
|
|
99
|
+ String oldPassword = params.get("oldPassword");
|
|
|
100
|
+ String newPassword = params.get("newPassword");
|
|
|
101
|
+ LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
102
|
+ String userName = loginUser.getUsername();
|
|
|
103
|
+ String password = loginUser.getSysUser().getPassword();
|
|
101
|
104
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
|
102
|
105
|
{
|
|
103
|
106
|
return error("修改密码失败,旧密码错误");
|
|
|
@@ -107,10 +110,9 @@ public class SysProfileController extends BaseController
|
|
107
|
110
|
return error("新密码不能与旧密码相同");
|
|
108
|
111
|
}
|
|
109
|
112
|
newPassword = SecurityUtils.encryptPassword(newPassword);
|
|
110
|
|
- if (userService.resetUserPwd(username, newPassword) > 0)
|
|
|
113
|
+ if (userService.resetUserPwd(userName, newPassword) > 0)
|
|
111
|
114
|
{
|
|
112
|
115
|
// 更新缓存用户密码
|
|
113
|
|
- LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
114
|
116
|
loginUser.getSysUser().setPassword(newPassword);
|
|
115
|
117
|
tokenService.setLoginUser(loginUser);
|
|
116
|
118
|
return success();
|