@@ -11,20 +11,9 @@ import (
11
11
"strings"
12
12
)
13
13
14
- type user struct {
15
- FullName string `json:"full_name,omitempty"`
16
- }
17
-
18
- type org struct {
19
- ID string
20
- Name string
21
- }
22
-
23
- type UserInfo struct {
24
- Profile user
25
- ID string
26
- Email string
27
- Org org
14
+ type OrgUserInfo struct {
15
+ Name string `json:"name,omitempty"`
16
+ OrgID string `json:"id,omitempty"`
28
17
}
29
18
30
19
type AuthService service
@@ -128,24 +117,23 @@ func (s *AuthService) LoginV2(ctx context.Context, email,
128
117
)
129
118
}
130
119
131
- info , err := s .UserInfo (ctx )
120
+ info , err := s .OrgUserInfo (ctx )
132
121
if err != nil {
133
122
return AuthResponse {}, err
134
123
}
135
- authResponse .FullName = info .Profile .FullName
136
- authResponse .Organization = info .Org .Name
137
- authResponse .OrganizationID = info .Org .ID
124
+ authResponse .Name = info .Name
125
+ authResponse .OrganizationID = info .OrgID
138
126
return authResponse , nil
139
127
}
140
128
141
- func (s * AuthService ) UserInfo (ctx context.Context ) (* UserInfo , error ) {
129
+ func (s * AuthService ) OrgUserInfo (ctx context.Context ) (* OrgUserInfo , error ) {
142
130
method := http .MethodGet
143
- req , err := s .client .NewRequest (method , "/konnect-api/api/userinfo/ " , nil , nil )
131
+ req , err := s .client .NewRequest (method , "/v2/organizations/me " , nil , nil )
144
132
if err != nil {
145
133
return nil , err
146
134
}
147
135
148
- info := & UserInfo {}
136
+ info := & OrgUserInfo {}
149
137
_ , err = s .client .Do (ctx , req , info )
150
138
if err != nil {
151
139
return nil , err
0 commit comments