Skip to content

Commit

Permalink
fix: 修改密码的旧密码错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
oddfar committed Dec 24, 2023
1 parent 5b15c9b commit d9f44c5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,20 @@ public R updateProfile(@RequestBody SysUserEntity user) {
*/
@PutMapping(value = "/updatePwd", name = "个人信息管理-重置密码")
public R updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
SysUserEntity user = userService.selectUserById(SecurityUtils.getUserId());
// LoginUser loginUser = getLoginUser();
String userName = user.getUserName();
String password = user.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return R.error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password)) {
return R.error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
// // 更新缓存用户密码
// loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
// tokenService.setLoginUser(loginUser);
return R.ok();
}
return R.error("修改密码异常,请联系管理员");
Expand Down

0 comments on commit d9f44c5

Please sign in to comment.