禅道#585问题修复

This commit is contained in:
gaoqr
2024-11-27 14:35:11 +08:00
parent b636c85c87
commit 1ea586b316
4 changed files with 14 additions and 9 deletions
@@ -24,7 +24,7 @@ public class AuthLoginSmsCheckReqVO {
private String mobile; private String mobile;
@Schema(description = "验证码", example = "123456") @Schema(description = "验证码", example = "123456")
@Length(min = 6, max = 6, message = "验证码长度必须 6 位") @Length(min = 6, max = 6, message = "短信验证码不正确")
@NotEmpty(message = "短信验证码不能为空") @NotEmpty(message = "短信验证码不能为空")
private String smsCaptchaVerification; private String smsCaptchaVerification;
} }
@@ -20,7 +20,7 @@ public class UserMobileUpdateReqVO {
private String mobile; private String mobile;
@Schema(description = "验证码", example = "123456") @Schema(description = "验证码", example = "123456")
@Length(min = 6, max = 6, message = "验证码长度必须 6 位") @Length(min = 6, max = 6, message = "短信验证码不正确")
@NotEmpty(message = "短信验证码不能为空") @NotEmpty(message = "短信验证码不能为空")
private String smsCaptchaVerification; private String smsCaptchaVerification;
} }
@@ -17,7 +17,7 @@ public class UserResetPasswordReqVO {
private String password; private String password;
@Schema(description = "短信验证码", example = "123456") @Schema(description = "短信验证码", example = "123456")
@Length(min = 6, max = 6, message = "短信验证码长度为 6 位") @Length(min = 6, max = 6, message = "短信验证码不正确")
@NotEmpty(message = "短信验证码不能为空") @NotEmpty(message = "短信验证码不能为空")
private String smsCaptchaVerification; private String smsCaptchaVerification;
@@ -119,7 +119,8 @@ public class AdminUserServiceImpl implements AdminUserService {
private static final String UPPER_LETTER_PATTERN = ".*[A-Z].*"; private static final String UPPER_LETTER_PATTERN = ".*[A-Z].*";
private static final String LOWER_LETTER_PATTERN = ".*[a-z].*"; private static final String LOWER_LETTER_PATTERN = ".*[a-z].*";
private static final String DIGIT_PATTERN = ".*\\d.*"; private static final String DIGIT_PATTERN = ".*\\d.*";
private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d]+$"; private static final String SPECIAL_CHARACTER_PATTERN = ".*[~!@#$%^&*()_+\\-=].*";
private static final String VALID_CHAR_PATTERN = "^[A-Za-z\\d~!@#$%^&*()_+\\-=]+$";
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@@ -506,19 +507,23 @@ public class AdminUserServiceImpl implements AdminUserService {
} }
// 检查是否包含大写字母 // 检查是否包含大写字母
if (!Pattern.matches(UPPER_LETTER_PATTERN, password)) { if (!Pattern.matches(UPPER_LETTER_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_UPPER_LETTER); throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
} }
// 检查是否包含小写字母 // 检查是否包含小写字母
if (!Pattern.matches(LOWER_LETTER_PATTERN, password)) { if (!Pattern.matches(LOWER_LETTER_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_LOWER_LETTER); throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
} }
// 检查是否包含数字 // 检查是否包含数字
if (!Pattern.matches(DIGIT_PATTERN, password)) { if (!Pattern.matches(DIGIT_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_MUST_CONTAIN_AT_LEAST_ONE_NUMBER); throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
} }
// 检查是否包含字母和数字 // 检查是否包含特殊字符
if (!Pattern.matches(SPECIAL_CHARACTER_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
}
// 检查是否只包含字母、数字和特殊字符
if (!Pattern.matches(VALID_CHAR_PATTERN, password)) { if (!Pattern.matches(VALID_CHAR_PATTERN, password)) {
throw ServiceExceptionUtil.exception(ErrorCodeConstants.PASSWORDS_CAN_ONLY_CONTAIN_LETTERS_AND_NUMBERS); throw ServiceExceptionUtil.exception(ErrorCodeConstants.THE_PASSWORD_LENGTH_MUST_BE_AT_LEAST_8_CHARACTERS);
} }
} }