diff --git a/cmd/ping.go b/cmd/ping.go index a7a7bf772..ce1711e90 100644 --- a/cmd/ping.go +++ b/cmd/ping.go @@ -53,12 +53,8 @@ func pingKonnect(ctx context.Context) error { if err != nil { return fmt.Errorf("authenticating with Konnect: %w", err) } - fullName := res.FullName - if res.FullName == "" { - fullName = fmt.Sprintf("%s %s", res.FirstName, res.LastName) - } - fmt.Printf("Successfully Konnected as %s (%s)!\n", - fullName, res.Organization) + + fmt.Printf("Successfully Konnected as %s organization!\n", res.Name) if konnectConfig.Debug { fmt.Printf("Organization ID: %s\n", res.OrganizationID) } diff --git a/konnect/login_service.go b/konnect/login_service.go index b796df74b..16147dbc2 100644 --- a/konnect/login_service.go +++ b/konnect/login_service.go @@ -11,20 +11,9 @@ import ( "strings" ) -type user struct { - FullName string `json:"full_name,omitempty"` -} - -type org struct { - ID string - Name string -} - -type UserInfo struct { - Profile user - ID string - Email string - Org org +type OrgUserInfo struct { + Name string `json:"name,omitempty"` + OrgID string `json:"id,omitempty"` } type AuthService service @@ -128,24 +117,23 @@ func (s *AuthService) LoginV2(ctx context.Context, email, ) } - info, err := s.UserInfo(ctx) + info, err := s.OrgUserInfo(ctx) if err != nil { return AuthResponse{}, err } - authResponse.FullName = info.Profile.FullName - authResponse.Organization = info.Org.Name - authResponse.OrganizationID = info.Org.ID + authResponse.Name = info.Name + authResponse.OrganizationID = info.OrgID return authResponse, nil } -func (s *AuthService) UserInfo(ctx context.Context) (*UserInfo, error) { +func (s *AuthService) OrgUserInfo(ctx context.Context) (*OrgUserInfo, error) { method := http.MethodGet - req, err := s.client.NewRequest(method, "/konnect-api/api/userinfo/", nil, nil) + req, err := s.client.NewRequest(method, "/v2/organizations/me", nil, nil) if err != nil { return nil, err } - info := &UserInfo{} + info := &OrgUserInfo{} _, err = s.client.Do(ctx, req, info) if err != nil { return nil, err diff --git a/konnect/types.go b/konnect/types.go index 15b0816f7..40d956027 100644 --- a/konnect/types.go +++ b/konnect/types.go @@ -137,10 +137,12 @@ type ControlPlaneType struct { // AuthResponse is authentication response wrapper for login. type AuthResponse struct { - Organization string `json:"org_name"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` + Name string `json:"name"` OrganizationID string `json:"org_id"` - FullName string `json:"full_name"` + // deprecated fields + Organization string `json:"org_name"` + FirstName string `json:"first_name"` + LastName string `json:"last_name"` + FullName string `json:"full_name"` }