|
@ -92,6 +92,10 @@ public class SysProfileController extends BaseController { |
|
|
public R<Void> updatePwd(@Validated @RequestBody SysUserPasswordBo bo) { |
|
|
public R<Void> updatePwd(@Validated @RequestBody SysUserPasswordBo bo) { |
|
|
SysUserVo user = userService.selectUserById(LoginHelper.getUserId()); |
|
|
SysUserVo user = userService.selectUserById(LoginHelper.getUserId()); |
|
|
String password = user.getPassword(); |
|
|
String password = user.getPassword(); |
|
|
|
|
|
String newPassword = bo.getNewPassword(); |
|
|
|
|
|
if (newPassword != null) { |
|
|
|
|
|
newPassword = newPassword.trim(); |
|
|
|
|
|
} |
|
|
if (!BCrypt.checkpw(bo.getOldPassword(), password)) { |
|
|
if (!BCrypt.checkpw(bo.getOldPassword(), password)) { |
|
|
return R.fail("修改密码失败,旧密码错误"); |
|
|
return R.fail("修改密码失败,旧密码错误"); |
|
|
} |
|
|
} |
|
@ -99,6 +103,11 @@ public class SysProfileController extends BaseController { |
|
|
return R.fail("新密码不能与旧密码相同"); |
|
|
return R.fail("新密码不能与旧密码相同"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 最小长度要求(5~20个字符)、大小写字母+数字+特殊字符组合
|
|
|
|
|
|
String regex = "^(?=.*[a-zA-Z])(?=.*\\d)(?=.*[~!@#$%^&*()_+`={}:;'<>?,./-])[a-zA-Z\\d~!@#$%^&*()_+`={}:;'<>?,./-]{5,20}$"; |
|
|
|
|
|
if (newPassword == null || !newPassword.matches(regex)) { |
|
|
|
|
|
return R.fail("新密码格式不正确,请输入5~20个字符,大小写字母+数字+特殊字符组合"); |
|
|
|
|
|
} |
|
|
if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(bo.getNewPassword())) > 0) { |
|
|
if (userService.resetUserPwd(user.getUserId(), BCrypt.hashpw(bo.getNewPassword())) > 0) { |
|
|
return R.ok(); |
|
|
return R.ok(); |
|
|
} |
|
|
} |
|
|