File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ limitations under the License.
16
16
package config
17
17
18
18
import (
19
+ "encoding/json"
19
20
"fmt"
21
+ "io"
20
22
"net/url"
21
23
"os"
22
24
"strings"
@@ -173,6 +175,37 @@ var setAccountCmd = &cobra.Command{
173
175
utils .PrintError (err )
174
176
}
175
177
utils .White_B .Printf ("\n account.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
+ }
176
209
} else {
177
210
utils .Red .Println ("\n Error: some flags are missing. Run 'litmusctl config set-account --help' for usage. " )
178
211
}
You can’t perform that action at this time.
0 commit comments