Skip to content

Commit

Permalink
Fix PasswordStrengthValidator not correctly validating MembershipSett…
Browse files Browse the repository at this point in the history
…ings.RequireDigit rule
  • Loading branch information
furkanevran committed Dec 30, 2024
1 parent 8e4d90f commit 87f3678
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class PasswordStrengthValidator(IOptions<MembershipSettings> membershipSe

public virtual void Validate(string password)
{
password ??= "";
password ??= string.Empty;

var rules = membershipSettings.Value;

if (password.Length < (rules.MinPasswordLength))
if (password.Length < rules.MinPasswordLength)
throw new ValidationError(nameof(MembershipSettings.MinPasswordLength), "Password",
string.Format(CultureInfo.CurrentCulture, PasswordStrengthValidationTexts.MinRequiredPasswordLength.ToString(localizer),
membershipSettings.Value.MinPasswordLength));
Expand Down Expand Up @@ -49,7 +49,7 @@ public virtual void Validate(string password)
throw new ValidationError(nameof(rules.RequireLowercase), "Password",
PasswordStrengthValidationTexts.PasswordStrengthRequireUppercase.ToString(localizer));

if (rules.RequireDigit && lowerCount == 0)
if (rules.RequireDigit && numericCount == 0)
throw new ValidationError(nameof(rules.RequireDigit), "Password",
PasswordStrengthValidationTexts.PasswordStrengthRequireDigit.ToString(localizer));

Expand Down

0 comments on commit 87f3678

Please sign in to comment.