优化特殊字符密码修改失败问题
This commit is contained in:
parent
b25a280ebb
commit
67b17da06f
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.system.controller;
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -93,11 +94,13 @@ public class SysProfileController extends BaseController
|
|||||||
*/
|
*/
|
||||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/updatePwd")
|
@PutMapping("/updatePwd")
|
||||||
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
public AjaxResult updatePwd(@RequestBody Map<String, String> params)
|
||||||
{
|
{
|
||||||
String username = SecurityUtils.getUsername();
|
String oldPassword = params.get("oldPassword");
|
||||||
SysUser user = userService.selectUserByUserName(username);
|
String newPassword = params.get("newPassword");
|
||||||
String password = user.getPassword();
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
String userName = loginUser.getUsername();
|
||||||
|
String password = loginUser.getSysUser().getPassword();
|
||||||
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
||||||
{
|
{
|
||||||
return error("修改密码失败,旧密码错误");
|
return error("修改密码失败,旧密码错误");
|
||||||
@ -107,10 +110,9 @@ public class SysProfileController extends BaseController
|
|||||||
return error("新密码不能与旧密码相同");
|
return error("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
newPassword = SecurityUtils.encryptPassword(newPassword);
|
newPassword = SecurityUtils.encryptPassword(newPassword);
|
||||||
if (userService.resetUserPwd(username, newPassword) > 0)
|
if (userService.resetUserPwd(userName, newPassword) > 0)
|
||||||
{
|
{
|
||||||
// 更新缓存用户密码
|
// 更新缓存用户密码
|
||||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
||||||
loginUser.getSysUser().setPassword(newPassword);
|
loginUser.getSysUser().setPassword(newPassword);
|
||||||
tokenService.setLoginUser(loginUser);
|
tokenService.setLoginUser(loginUser);
|
||||||
return success();
|
return success();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||||||
return request({
|
return request({
|
||||||
url: '/system/user/profile/updatePwd',
|
url: '/system/user/profile/updatePwd',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
params: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user