Commit 654783e3 by 刘红梅

验证密码格式

parent 3ae486e0
......@@ -113,6 +113,7 @@ public class LoginServiceImpl implements LoginService {
ValidUtils.isText(loginVO.getPhoneCode(), "请输入验证码");
ValidUtils.isTrue(Validator.isMobile(loginVO.getPhoneNumber()), "请输入正确格式的手机号");
ValidUtils.isText(loginVO.getPassword(), "请输入密码");
ValidUtils.isValidPassword(loginVO.getPassword(),GlobalErrorCodeConstants.PARAM_PASSWORD_FORMAT_ERROR);
//1.根据手机号去库中查询是否存在
ExpertInfoResp expertInfoResp = loginServicesClient.querySingleByShengFenZhengOrMobile(loginVO.getPhoneNumber(),null);
if(expertInfoResp == null){
......@@ -160,6 +161,7 @@ public class LoginServiceImpl implements LoginService {
ValidUtils.isText(loginVO.getIdNumber(), "请输入身份证号");
ValidUtils.isText(loginVO.getPassword(), "请输入密码");
ValidUtils.isTrue(IdcardUtil.isValidCard(loginVO.getIdNumber()), "请输入正确的身份证号");
ValidUtils.isValidPassword(loginVO.getPassword(),GlobalErrorCodeConstants.PARAM_PASSWORD_FORMAT_ERROR);
ExpertInfoResp expertInfoResp = loginServicesClient.querySingleByShengFenZhengOrMobile(null,loginVO.getIdNumber());
if(expertInfoResp == null){
throw new BusinessException(GlobalErrorCodeConstants.USER_NOT_EXISTS.getCode(),GlobalErrorCodeConstants.USER_NOT_EXISTS.getMsg());
......
......@@ -31,6 +31,7 @@ public interface GlobalErrorCodeConstants {
ErrorCode PARAM_REQUIRED = new ErrorCode(3001, "必填字段不能为空");
ErrorCode PARAM_FORMAT_ERROR = new ErrorCode(3002, "参数格式不正确");
ErrorCode PARAM_RANGE_ERROR = new ErrorCode(3003, "参数超出范围");
ErrorCode PARAM_PASSWORD_FORMAT_ERROR = new ErrorCode(3004, "密码强度不符合要求:密码必须包含大小写字母、数字和特殊字符,且长度不少于8位");
// ========== 业务逻辑错误 (4000-4999) ==========
ErrorCode OPERATION_TOO_FREQUENT = new ErrorCode(4001, "操作太频繁,请稍后再试");
......
......@@ -90,5 +90,11 @@ public class ValidUtils {
}
}
//判断是否有效的密码
public static void isValidPassword(String password, ErrorCode errorCode) {
String passwordRegex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`])[a-zA-Z\\d!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?~`]{8,}$";
if (!password.matches(passwordRegex)) {
throw new BusinessException(errorCode.getCode(), errorCode.getMsg());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment