Skip to content

Commit

Permalink
update password regex valid
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyunchong committed May 19, 2024
1 parent 1fc9764 commit ee9357c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/LinCms.Application.Contracts/Cms/Account/RegisterDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class RegisterEmailCodeInput : IValidatableObject
[Required(ErrorMessage = "邮件不能为空")]
public string Email { get; set; }


public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (!Email.IsNullOrEmpty())
Expand Down Expand Up @@ -50,7 +49,7 @@ public class RegisterDto : RegisterEmailCodeInput
/// 密码
/// </summary>
[Required(ErrorMessage = "新密码不可为空")]
[RegularExpression("^[A-Za-z0-9_*&$#@]{6,22}$", ErrorMessage = "密码长度必须在6~22位之间,包含字符、数字和 _")]
[RegularExpression(AccountContract.PasswordRegex, ErrorMessage = AccountContract.PasswordErrorMessage)]
public string Password { get; set; }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public class ResetEmailPasswordDto
[Required(ErrorMessage = "请输入验证码")]
public string ResetCode { get; set; }
[Required(ErrorMessage = "请输入你的新密码")]
[RegularExpression("^[A-Za-z0-9_*&$#@]{6,22}$", ErrorMessage = "密码长度必须在6~22位之间,包含字符、数字和 _")]
[RegularExpression(AccountContract.PasswordRegex, ErrorMessage = AccountContract.PasswordErrorMessage)]
public string Password { get; set; }
}

public class AccountContract
{
public const string PasswordRegex = "^(?![a-zA-Z]+$)(?!\\d+$)(?![^\\da-zA-Z\\s]+$).{6,20}$";
public const string PasswordErrorMessage = "密码由字母、数字、特殊字符,任意2种组成,长度在6-20个字符之间";
}

0 comments on commit ee9357c

Please sign in to comment.