Skip to content

Commit 8aeb2d1

Browse files
committed
revert changes
1 parent 8ca7fac commit 8aeb2d1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/cmd/config/setAccount.go

+33
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ limitations under the License.
1616
package config
1717

1818
import (
19+
"encoding/json"
1920
"fmt"
21+
"io"
2022
"net/url"
2123
"os"
2224
"strings"
@@ -173,6 +175,37 @@ var setAccountCmd = &cobra.Command{
173175
utils.PrintError(err)
174176
}
175177
utils.White_B.Printf("\naccount.username/%s configured", claims["username"].(string))
178+
credentials, err := utils.GetCredentials(cmd)
179+
if err != nil {
180+
utils.PrintError(err)
181+
}
182+
endpoint := credentials.Endpoint + utils.AuthAPIPath + "/get_user/" + claims["uid"].(string)
183+
userResp, err := apis.SendRequest(
184+
apis.SendRequestParams{
185+
Endpoint: endpoint,
186+
Token: "Bearer " + credentials.Token,
187+
},
188+
nil,
189+
string(types.Get),
190+
)
191+
if err != nil {
192+
utils.PrintError(err)
193+
}
194+
bodyBytes, err := io.ReadAll(userResp.Body)
195+
if err != nil {
196+
utils.PrintError(err)
197+
}
198+
var userResponse map[string]interface{}
199+
err = json.Unmarshal(bodyBytes, &userResponse)
200+
if err != nil {
201+
utils.PrintError(err)
202+
}
203+
204+
isInitialLogin := userResponse["isInitialLogin"].(bool)
205+
if isInitialLogin {
206+
utils.White_B.Println("\n❗ This is your first time login. Update your default password to perform further operations.")
207+
utils.White.Println(fmt.Sprintf("Use '%s' to update your password.", utils.White_B.Sprint("litmusctl update password")))
208+
}
176209
} else {
177210
utils.Red.Println("\nError: some flags are missing. Run 'litmusctl config set-account --help' for usage. ")
178211
}

0 commit comments

Comments
 (0)