Skip to content

Commit

Permalink
优化特殊字符密码修改失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Dec 17, 2024
1 parent b25a280 commit 67b17da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ruoyi.system.controller;

import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -93,11 +94,13 @@ public AjaxResult updateProfile(@RequestBody SysUser user)
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
{
String username = SecurityUtils.getUsername();
SysUser user = userService.selectUserByUserName(username);
String password = user.getPassword();
String oldPassword = params.get("oldPassword");
String newPassword = params.get("newPassword");
LoginUser loginUser = SecurityUtils.getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getSysUser().getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return error("修改密码失败,旧密码错误");
Expand All @@ -107,10 +110,9 @@ public AjaxResult updatePwd(String oldPassword, String newPassword)
return error("新密码不能与旧密码相同");
}
newPassword = SecurityUtils.encryptPassword(newPassword);
if (userService.resetUserPwd(username, newPassword) > 0)
if (userService.resetUserPwd(userName, newPassword) > 0)
{
// 更新缓存用户密码
LoginUser loginUser = SecurityUtils.getLoginUser();
loginUser.getSysUser().setPassword(newPassword);
tokenService.setLoginUser(loginUser);
return success();
Expand Down
2 changes: 1 addition & 1 deletion ruoyi-ui/src/api/system/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function updateUserPwd(oldPassword, newPassword) {
return request({
url: '/system/user/profile/updatePwd',
method: 'put',
params: data
data: data
})
}

Expand Down

0 comments on commit 67b17da

Please sign in to comment.