Bläddra i källkod

优化特殊字符密码修改失败问题

RuoYi 1 år sedan
förälder
incheckning
67b17da06f

+ 8 - 6
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysProfileController.java

@@ -1,6 +1,7 @@
1
 package com.ruoyi.system.controller;
1
 package com.ruoyi.system.controller;
2
 
2
 
3
 import java.util.Arrays;
3
 import java.util.Arrays;
4
+import java.util.Map;
4
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.web.bind.annotation.GetMapping;
6
 import org.springframework.web.bind.annotation.GetMapping;
6
 import org.springframework.web.bind.annotation.PostMapping;
7
 import org.springframework.web.bind.annotation.PostMapping;
@@ -93,11 +94,13 @@ public class SysProfileController extends BaseController
93
      */
94
      */
94
     @Log(title = "个人信息", businessType = BusinessType.UPDATE)
95
     @Log(title = "个人信息", businessType = BusinessType.UPDATE)
95
     @PutMapping("/updatePwd")
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
         if (!SecurityUtils.matchesPassword(oldPassword, password))
104
         if (!SecurityUtils.matchesPassword(oldPassword, password))
102
         {
105
         {
103
             return error("修改密码失败,旧密码错误");
106
             return error("修改密码失败,旧密码错误");
@@ -107,10 +110,9 @@ public class SysProfileController extends BaseController
107
             return error("新密码不能与旧密码相同");
110
             return error("新密码不能与旧密码相同");
108
         }
111
         }
109
         newPassword = SecurityUtils.encryptPassword(newPassword);
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
             loginUser.getSysUser().setPassword(newPassword);
116
             loginUser.getSysUser().setPassword(newPassword);
115
             tokenService.setLoginUser(loginUser);
117
             tokenService.setLoginUser(loginUser);
116
             return success();
118
             return success();

+ 1 - 1
ruoyi-ui/src/api/system/user.js

@@ -96,7 +96,7 @@ export function updateUserPwd(oldPassword, newPassword) {
96
   return request({
96
   return request({
97
     url: '/system/user/profile/updatePwd',
97
     url: '/system/user/profile/updatePwd',
98
     method: 'put',
98
     method: 'put',
99
-    params: data
99
+    data: data
100
   })
100
   })
101
 }
101
 }
102
 
102