Merge pull request #4451 from swordqiu/feature/qj-skip-user-create-password-complexity-check

feature: allow skip password complexity check when creating user
This commit is contained in:
Zexi Li
2019-12-31 18:05:12 +08:00
committed by GitHub
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -159,6 +159,8 @@ func init() {
Enabled bool `help:"Enabled"`
Disabled bool `help:"Disabled"`
SkipPasswordComplexityCheck bool `help:"do password complexity check, default is false"`
// DefaultProject string `help:"Default project"`
SystemAccount bool `help:"is a system account?"`
NoWebConsole bool `help:"allow web console access"`
@@ -176,6 +178,9 @@ func init() {
}
if args.Password != nil {
params.Add(jsonutils.NewString(*args.Password), "password")
if args.SkipPasswordComplexityCheck {
params.Add(jsonutils.JSONTrue, "skip_password_complexity_check")
}
}
if len(args.Displayname) > 0 {
params.Add(jsonutils.NewString(args.Displayname), "displayname")
+1 -1
View File
@@ -389,7 +389,7 @@ func (manager *SUserManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery,
}
func (manager *SUserManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
if data.Contains("password") {
if data.Contains("password") && !jsonutils.QueryBoolean(data, "skip_password_complexity_check", false) {
passwd, _ := data.GetString("password")
err := validatePasswordComplexity(passwd)
if err != nil {