This commit is contained in:
parent
170051e46f
commit
42cd4e2f55
|
|
@ -614,9 +614,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 检查密码字符类型
|
// 2. 检查密码字符类型
|
||||||
if (!isPasswordCharacterValid(decrypt)) {
|
isPasswordCharacterValid(decrypt);
|
||||||
throw new ServiceException(getCharacterRequirementErrorMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 检查常见弱密码
|
// 3. 检查常见弱密码
|
||||||
if (containsWeakPassword(decrypt.toLowerCase())) {
|
if (containsWeakPassword(decrypt.toLowerCase())) {
|
||||||
|
|
@ -754,7 +752,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
* @param password
|
* @param password
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isPasswordCharacterValid(String password) {
|
private void isPasswordCharacterValid(String password) {
|
||||||
boolean hasUpperCase = false, hasLowerCase = false, hasDigit = false, hasSpecialChar = false;
|
boolean hasUpperCase = false, hasLowerCase = false, hasDigit = false, hasSpecialChar = false;
|
||||||
|
|
||||||
for (char c : password.toCharArray()) {
|
for (char c : password.toCharArray()) {
|
||||||
|
|
@ -773,15 +771,17 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemConfig.getPasswordConfig().isRequireUpperCase() && !hasUpperCase) {
|
if (systemConfig.getPasswordConfig().isRequireUpperCase() && !hasUpperCase) {
|
||||||
return false;
|
throw new ServiceException("新密码必须包含大写字母!");
|
||||||
}
|
}
|
||||||
if (systemConfig.getPasswordConfig().isRequireLowerCase() && !hasLowerCase) {
|
if (systemConfig.getPasswordConfig().isRequireLowerCase() && !hasLowerCase) {
|
||||||
return false;
|
throw new ServiceException("新密码必须包含小写字母!");
|
||||||
}
|
}
|
||||||
if (systemConfig.getPasswordConfig().isRequireDigit() && !hasDigit) {
|
if (systemConfig.getPasswordConfig().isRequireDigit() && !hasDigit) {
|
||||||
return false;
|
throw new ServiceException("新密码必须包含数字!");
|
||||||
|
}
|
||||||
|
if (systemConfig.getPasswordConfig().isRequireSpecialChar() && !hasSpecialChar) {
|
||||||
|
throw new ServiceException("新密码必须包含特殊字符!");
|
||||||
}
|
}
|
||||||
return !(systemConfig.getPasswordConfig().isRequireSpecialChar() && !hasSpecialChar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue