mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-01 13:32:35 +08:00
fix: reset user password without check
This commit is contained in:
@@ -262,6 +262,8 @@ func init() {
|
||||
|
||||
// DefaultProject string `help:"Default project"`
|
||||
// Option []string `help:"User options"`
|
||||
|
||||
SkipPasswordComplexityCheck bool `help:"skip_password_complexity_check"`
|
||||
}
|
||||
R(&UserUpdateOptions{}, "user-update", "Update a user", func(s *mcclient.ClientSession, args *UserUpdateOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -282,6 +284,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")
|
||||
|
||||
@@ -429,6 +429,8 @@ type UserUpdateInput struct {
|
||||
EnableMfa *bool `json:"enable_mfa"`
|
||||
|
||||
Password string `json:"password"`
|
||||
|
||||
SkipPasswordComplexityCheck *bool `json:"skip_password_complexity_check"`
|
||||
}
|
||||
|
||||
type UserCreateInput struct {
|
||||
|
||||
@@ -432,7 +432,7 @@ func (model *SIdentityBaseResource) PostCreate(ctx context.Context, userCred mcc
|
||||
|
||||
func (model *SIdentityBaseResource) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
model.SStandaloneResourceBase.PostUpdate(ctx, userCred, query, data)
|
||||
logclient.AddActionLogWithContext(ctx, model, logclient.ACT_UPDATE, data, userCred, true)
|
||||
// logclient.AddActionLogWithContext(ctx, model, logclient.ACT_UPDATE, data, userCred, true)
|
||||
}
|
||||
|
||||
func (model *SIdentityBaseResource) PostDelete(ctx context.Context, userCred mcclient.TokenCredential) {
|
||||
|
||||
@@ -517,7 +517,7 @@ func (user *SUser) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(input.Password) > 0 {
|
||||
if len(input.Password) > 0 && (input.SkipPasswordComplexityCheck == nil || *input.SkipPasswordComplexityCheck == false) {
|
||||
passwd := input.Password
|
||||
usrExt, err := UserManager.FetchUserExtended(user.Id, "", "", "")
|
||||
if err != nil {
|
||||
@@ -722,6 +722,7 @@ func (user *SUser) PostUpdate(ctx context.Context, userCred mcclient.TokenCreden
|
||||
log.Errorf("fail to set password %s", err)
|
||||
return
|
||||
}
|
||||
logclient.AddActionLogWithContext(ctx, user, logclient.ACT_UPDATE_PASSWORD, nil, userCred, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -190,6 +190,8 @@ const (
|
||||
|
||||
ACT_UPDATE_STATUS = "更新状态"
|
||||
|
||||
ACT_UPDATE_PASSWORD = "更新密码"
|
||||
|
||||
ACT_REMOVE_GUEST = "移除实例"
|
||||
ACT_CREATE_SCALING_POLICY = "创建伸缩策略"
|
||||
ACT_DELETE_SCALING_POLICY = "删除伸缩策略"
|
||||
|
||||
Reference in New Issue
Block a user