fix for openziti/edge#191
@@ -21,6 +21,7 @@ import (
"fmt"
"github.com/Jeffail/gabs"
"github.com/openziti/foundation/util/term"
+ "github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/spf13/cobra"
)
import cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
@@ -96,10 +97,28 @@ func updateSelfPassword(current string, new string, options commonOptions) error
}
passwordData := gabs.New()
- setJSONValue(passwordData, current, "current")
- setJSONValue(passwordData, new, "new")
+ setJSONValue(passwordData, current, "currentPassword")
+ setJSONValue(passwordData, new, "password")
- _, err = putEntityOfType("current-identity/updb/password", passwordData.String(), &options)
+ respEnvelope, err := util.EdgeControllerList("current-identity/authenticators", map[string][]string{"filter": {`method="updb"`}}, options.OutputJSONResponse, options.Out)
+
+ if err != nil {
+ return err
+ }
+
+ authenticators, err := respEnvelope.S("data").Children()
+
+ if err != nil {
+ return err
+ }
+
+ if len(authenticators) == 0 {
+ return errors.New("no updb authenticator found for the current identity")
+ } else if len(authenticators) > 1 {
+ return errors.New("too many updb authenticator found for the current identity")
+ }
+
+ _, err = patchEntityOfType("current-identity/authenticators/"+authenticators[0].Path("id").Data().(string), passwordData.String(), &options)
if err != nil {
return err
