MCPcopy Create free account
hub / github.com/cli/cli / userOrgLogins

Method userOrgLogins

pkg/cmd/project/shared/queries/queries.go:1361–1397  ·  view source on GitHub ↗

userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of.

()

Source from the content-addressed store, hash-verified

1359
1360// userOrgLogins gets all the logins of the viewer and the organizations the viewer is a member of.
1361func (c *Client) userOrgLogins() ([]loginTypes, error) {
1362 l := make([]loginTypes, 0)
1363 var v viewerLoginOrgs
1364 variables := map[string]any{
1365 "after": (*githubv4.String)(nil),
1366 }
1367
1368 err := c.doQueryWithProgressIndicator("ViewerLoginAndOrgs", &v, variables)
1369 if err != nil {
1370 return l, err
1371 }
1372
1373 // add the user
1374 l = append(l, loginTypes{
1375 Login: v.Viewer.Login,
1376 Type: ViewerOwner,
1377 ID: v.Viewer.ID,
1378 })
1379
1380 // add orgs where the user can create projects
1381 for _, org := range v.Viewer.Organizations.Nodes {
1382 if org.ViewerCanCreateProjects {
1383 l = append(l, loginTypes{
1384 Login: org.Login,
1385 Type: OrgOwner,
1386 ID: org.ID,
1387 })
1388 }
1389 }
1390
1391 // this seem unlikely, but if there are more org logins, paginate the rest
1392 if v.Viewer.Organizations.PageInfo.HasNextPage {
1393 return c.paginateOrgLogins(l, string(v.Viewer.Organizations.PageInfo.EndCursor))
1394 }
1395
1396 return l, nil
1397}
1398
1399// paginateOrgLogins after cursor and append them to the list of logins.
1400func (c *Client) paginateOrgLogins(l []loginTypes, cursor string) ([]loginTypes, error) {

Callers 1

NewOwnerMethod · 0.95

Calls 2

paginateOrgLoginsMethod · 0.95

Tested by

no test coverage detected