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

Method userOrgLogins

pkg/cmd/project/shared/queries/queries.go:1362–1398  ·  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

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