From b5a7240375505fa255c67e1cb4917dcffad93dc4 Mon Sep 17 00:00:00 2001 From: Daniel Hougaard <62331820+DanielHougaard@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:52:48 +0100 Subject: [PATCH] Fix: Select org when using `init` --- cli/packages/cmd/init.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cli/packages/cmd/init.go b/cli/packages/cmd/init.go index e47eb447e..99d2ef502 100644 --- a/cli/packages/cmd/init.go +++ b/cli/packages/cmd/init.go @@ -74,6 +74,21 @@ var initCmd = &cobra.Command{ selectedOrganization := organizations[index] + tokenResponse, err := api.CallSelectOrganization(httpClient, api.SelectOrganizationRequest{OrganizationId: selectedOrganization.ID}) + + if err != nil { + util.HandleError(err, "Unable to select organization") + } + + // set the config jwt token to the new token + userCreds.UserCredentials.JTWToken = tokenResponse.Token + err = util.StoreUserCredsInKeyRing(&userCreds.UserCredentials) + httpClient.SetAuthToken(tokenResponse.Token) + + if err != nil { + util.HandleError(err, "Unable to store your user credentials") + } + workspaceResponse, err := api.CallGetAllWorkSpacesUserBelongsTo(httpClient) if err != nil { util.HandleError(err, "Unable to pull projects that belong to you")