密码复杂度

This commit is contained in:
sxu 2025-04-25 14:30:08 +08:00
parent e742bdda37
commit c458cf1534
1 changed files with 6 additions and 2 deletions

View File

@ -243,7 +243,7 @@ public class CustInfoServiceImpl extends ServiceImpl<CustInfoMapper, CustInfo> i
// 2. 检查密码字符类型
if (!isPasswordCharacterValid(newPassword)) {
return AjaxResult.error("密码不符合字符要求");
return AjaxResult.error("密码必须包含大、小字母、数字、特殊字符");
}
// 3. 检查常见弱密码
@ -257,7 +257,7 @@ public class CustInfoServiceImpl extends ServiceImpl<CustInfoMapper, CustInfo> i
}
// 5. 检查新旧密码是否相同
if (SecurityUtils.matchesPassword(newPassword, oldPassword)) {
if (StringUtils.isNotEmpty(oldPassword) && SecurityUtils.matchesPassword(newPassword, oldPassword)) {
return AjaxResult.error("新密码不能与原密码相同!");
}
@ -444,6 +444,10 @@ public class CustInfoServiceImpl extends ServiceImpl<CustInfoMapper, CustInfo> i
ajaxResult.put("code", "500");
} else {
String newPassword = content.getNewPassword();
AjaxResult pwdCheckResult = validatePassword(null, newPassword);
if (ajaxResult.isError()) {
return pwdCheckResult;
}
BCryptPasswordEncoder bCrypt = new BCryptPasswordEncoder();
String password = bCrypt.encode(newPassword);
custInfo.setPwd(password);