|
|
@ -88,13 +88,14 @@ public class SysProfileController extends BaseController { |
|
|
@PostMapping({"/updatePwd"}) |
|
|
@PostMapping({"/updatePwd"}) |
|
|
public AjaxResult updatePwd(String oldPassword, String newPassword) { |
|
|
public AjaxResult updatePwd(String oldPassword, String newPassword) { |
|
|
String username = SecurityUtils.getUsername(); |
|
|
String username = SecurityUtils.getUsername(); |
|
|
|
|
|
Long userId = SecurityUtils.getUserId(); |
|
|
SysUser user = this.userService.selectUserByUserName(username); |
|
|
SysUser user = this.userService.selectUserByUserName(username); |
|
|
String password = user.getPassword(); |
|
|
String password = user.getPassword(); |
|
|
if (!SecurityUtils.matchesPassword(oldPassword, password)) { |
|
|
if (!SecurityUtils.matchesPassword(oldPassword, password)) { |
|
|
return AjaxResult.error("修改密码失败,旧密码错误"); |
|
|
return AjaxResult.error("修改密码失败,旧密码错误"); |
|
|
} else if (SecurityUtils.matchesPassword(newPassword, password)) { |
|
|
} else if (SecurityUtils.matchesPassword(newPassword, password)) { |
|
|
return AjaxResult.error("新密码不能与旧密码相同"); |
|
|
return AjaxResult.error("新密码不能与旧密码相同"); |
|
|
} else if (this.userService.resetUserPwd(username, SecurityUtils.encryptPassword(newPassword)) > 0) { |
|
|
|
|
|
|
|
|
} else if (this.userService.resetUserPwd(userId, SecurityUtils.encryptPassword(newPassword)) > 0) { |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
String userKey = this.tokenService.getTokenKey(loginUser.getToken()); |
|
|
String userKey = this.tokenService.getTokenKey(loginUser.getToken()); |
|
|
this.redisService.deleteObject(userKey); |
|
|
this.redisService.deleteObject(userKey); |
|
|
|