Skip to content

Commit

Permalink
Merge pull request #1117 from ksamoray/user_pass_update
Browse files Browse the repository at this point in the history
Handle password change in update
  • Loading branch information
ksamoray authored Feb 15, 2024
2 parents 4f31cce + 24c9424 commit 726a519
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nsxt/resource_nsxt_node_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ func resourceNsxtNodeUserUpdate(d *schema.ResourceData, m interface{}) error {
if id == "" {
return fmt.Errorf("error obtaining logical object id")
}
password := d.Get("password").(string)
oldPwd, pwd := d.GetChange("password")
password := pwd.(string)
oldPassword := oldPwd.(string)

active := d.Get("active").(bool)
status := d.Get("status").(string)

Expand Down Expand Up @@ -207,6 +210,13 @@ func resourceNsxtNodeUserUpdate(d *schema.ResourceData, m interface{}) error {
PasswordChangeWarning: &passwordChangeWarning,
Username: &username,
}

// If password is changed, handle password change.
if password != oldPassword {
userProp.Password = &password
userProp.OldPassword = &oldPassword
}

_, err := client.Update(id, userProp)
if err != nil {
return handleUpdateError("User", id, err)
Expand Down

0 comments on commit 726a519

Please sign in to comment.