flipped-aurora/gin-vue-admin · warning

密码必须包含%s

Error message

密码必须包含%s

What it means

After checking length, ValidatePasswordComplexity verifies character-class requirements (uppercase, lowercase, digits, special characters). Each enabled requirement in cfg that the password fails is collected and reported as "密码必须包含%s" with the missing classes joined by "、". It tells the user exactly which character categories to add.

Source

Thrown at server/utils/password_complexity.go:44

		case unicode.IsPunct(r) || unicode.IsSymbol(r):
			hasSpecial = true
		}
	}
	var missing []string
	if cfg.PwdRequireUpper && !hasUpper {
		missing = append(missing, "大写字母")
	}
	if cfg.PwdRequireLower && !hasLower {
		missing = append(missing, "小写字母")
	}
	if cfg.PwdRequireDigit && !hasDigit {
		missing = append(missing, "数字")
	}
	if cfg.PwdRequireSpecial && !hasSpecial {
		missing = append(missing, "特殊字符")
	}
	if len(missing) > 0 {
		return fmt.Errorf("密码必须包含%s", strings.Join(missing, "、"))
	}
	return nil
}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Add the missing character classes named in the error (uppercase, lowercase, 数字, 特殊字符).
  2. Mirror the enabled requirements (PwdRequireUpper/Lower/Digit/Special) in the frontend validation and hint text.
  3. If policy is too strict for your users, disable the corresponding PwdRequire* flags in the security config.

Example fix

// before
ValidatePasswordComplexity("Password", cfg) // missing digit & special

// after
ValidatePasswordComplexity("Password1!", cfg) // passes all classes
Defensive patterns

Strategy: validation

Validate before calling

func meetsClasses(pwd string, cfg system.SysSecurityConfig) []string {
    var missing []string
    var up, low, dig, sp bool
    for _, r := range pwd {
        switch {
        case unicode.IsUpper(r): up = true
        case unicode.IsLower(r): low = true
        case unicode.IsDigit(r): dig = true
        default: sp = true
        }
    }
    if cfg.PwdRequireUpper && !up { missing = append(missing, "uppercase") }
    if cfg.PwdRequireLower && !low { missing = append(missing, "lowercase") }
    if cfg.PwdRequireDigit && !dig { missing = append(missing, "digit") }
    if cfg.PwdRequireSpecial && !sp { missing = append(missing, "special") }
    return missing
}

Try / catch

if err := utils.ValidatePasswordComplexity(pwd, cfg); err != nil {
    return c.BadRequest(err.Error()) // lists missing classes verbatim
}

Prevention

When it happens

Trigger: Calling ValidatePasswordComplexity with a password lacking one or more required classes — e.g. cfg.PwdRequireDigit is true but the password has no digits, or PwdRequireSpecial is true but there is no special character.

Common situations: Users submit alphabetic-only passwords when policy requires digits/specials; newly enabled complexity flags in security config reject old passwords during reset; multi-byte special characters counted unexpectedly.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/6350432f5b83e974. Report an issue: GitHub.