From 8ca7faca8ea4570d21461a833cdc86c2c2918229 Mon Sep 17 00:00:00 2001 From: Baalekshan Date: Wed, 18 Sep 2024 18:04:46 +0530 Subject: [PATCH 1/3] docs: added usage for update password command Signed-off-by: Baalekshan --- Usage_0.23.0.md | 12 ++++++++++++ Usage_interactive.md | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Usage_0.23.0.md b/Usage_0.23.0.md index 186550e..c78df43 100644 --- a/Usage_0.23.0.md +++ b/Usage_0.23.0.md @@ -237,6 +237,18 @@ Enter the Chaos Experiment ID: test_exp ### Additional commands +- To change the ChaosCenter account's password use the `update password` command: + +```shell +litmusctl update password +✓ Username: admin +✓ Old Password: ******** +✓ New Password: ******** +✓ Confirm Password: ******** + +Password updated successfully! +``` + - To view the current configuration of `.litmusconfig`, type: ```shell diff --git a/Usage_interactive.md b/Usage_interactive.md index 3130686..632e4d2 100644 --- a/Usage_interactive.md +++ b/Usage_interactive.md @@ -200,6 +200,18 @@ litmusctl create chaos-scenario -f custom-chaos-scenario.yml --project-id="" --c ### Additional commands +- To change the ChaosCenter account's password use the `update password` command: + +```shell +litmusctl update password +✓ Username: admin +✓ Old Password: ******** +✓ New Password: ******** +✓ Confirm Password: ******** + +Password updated successfully! +``` + - To view the current configuration of `.litmusconfig`, type: ```shell From 8aeb2d1fd090312a365ab555197b26ad551f97cc Mon Sep 17 00:00:00 2001 From: Baalekshan Date: Sun, 20 Oct 2024 17:03:55 +0530 Subject: [PATCH 2/3] revert changes --- pkg/cmd/config/setAccount.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/cmd/config/setAccount.go b/pkg/cmd/config/setAccount.go index 1634de7..bbcde41 100644 --- a/pkg/cmd/config/setAccount.go +++ b/pkg/cmd/config/setAccount.go @@ -16,7 +16,9 @@ limitations under the License. package config import ( + "encoding/json" "fmt" + "io" "net/url" "os" "strings" @@ -173,6 +175,37 @@ var setAccountCmd = &cobra.Command{ utils.PrintError(err) } utils.White_B.Printf("\naccount.username/%s configured", claims["username"].(string)) + credentials, err := utils.GetCredentials(cmd) + if err != nil { + utils.PrintError(err) + } + endpoint := credentials.Endpoint + utils.AuthAPIPath + "/get_user/" + claims["uid"].(string) + userResp, err := apis.SendRequest( + apis.SendRequestParams{ + Endpoint: endpoint, + Token: "Bearer " + credentials.Token, + }, + nil, + string(types.Get), + ) + if err != nil { + utils.PrintError(err) + } + bodyBytes, err := io.ReadAll(userResp.Body) + if err != nil { + utils.PrintError(err) + } + var userResponse map[string]interface{} + err = json.Unmarshal(bodyBytes, &userResponse) + if err != nil { + utils.PrintError(err) + } + + isInitialLogin := userResponse["isInitialLogin"].(bool) + if isInitialLogin { + utils.White_B.Println("\n❗ This is your first time login. Update your default password to perform further operations.") + utils.White.Println(fmt.Sprintf("Use '%s' to update your password.", utils.White_B.Sprint("litmusctl update password"))) + } } else { utils.Red.Println("\nError: some flags are missing. Run 'litmusctl config set-account --help' for usage. ") } From 0e49a619ea294a02c571e1aa7cfea300b527b906 Mon Sep 17 00:00:00 2001 From: Baalekshan Date: Sun, 20 Oct 2024 17:06:33 +0530 Subject: [PATCH 3/3] Revert "revert changes" This reverts commit 8aeb2d1fd090312a365ab555197b26ad551f97cc. --- pkg/cmd/config/setAccount.go | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/pkg/cmd/config/setAccount.go b/pkg/cmd/config/setAccount.go index bbcde41..1634de7 100644 --- a/pkg/cmd/config/setAccount.go +++ b/pkg/cmd/config/setAccount.go @@ -16,9 +16,7 @@ limitations under the License. package config import ( - "encoding/json" "fmt" - "io" "net/url" "os" "strings" @@ -175,37 +173,6 @@ var setAccountCmd = &cobra.Command{ utils.PrintError(err) } utils.White_B.Printf("\naccount.username/%s configured", claims["username"].(string)) - credentials, err := utils.GetCredentials(cmd) - if err != nil { - utils.PrintError(err) - } - endpoint := credentials.Endpoint + utils.AuthAPIPath + "/get_user/" + claims["uid"].(string) - userResp, err := apis.SendRequest( - apis.SendRequestParams{ - Endpoint: endpoint, - Token: "Bearer " + credentials.Token, - }, - nil, - string(types.Get), - ) - if err != nil { - utils.PrintError(err) - } - bodyBytes, err := io.ReadAll(userResp.Body) - if err != nil { - utils.PrintError(err) - } - var userResponse map[string]interface{} - err = json.Unmarshal(bodyBytes, &userResponse) - if err != nil { - utils.PrintError(err) - } - - isInitialLogin := userResponse["isInitialLogin"].(bool) - if isInitialLogin { - utils.White_B.Println("\n❗ This is your first time login. Update your default password to perform further operations.") - utils.White.Println(fmt.Sprintf("Use '%s' to update your password.", utils.White_B.Sprint("litmusctl update password"))) - } } else { utils.Red.Println("\nError: some flags are missing. Run 'litmusctl config set-account --help' for usage. ") }