mirror of https://github.com/coder/coder.git
fix: Fetch all GitHub teams on login (#2951)
This wasn't looping prior, so organizations with >100 teams couldn't login. Contributes to #2848.
This commit is contained in:
parent
59facdd8dc
commit
5ee112bc00
|
@ -771,10 +771,23 @@ func configureGithubOAuth2(accessURL *url.URL, clientID, clientSecret string, al
|
|||
return memberships, err
|
||||
},
|
||||
ListTeams: func(ctx context.Context, client *http.Client, org string) ([]*github.Team, error) {
|
||||
teams, _, err := github.NewClient(client).Teams.ListTeams(ctx, org, &github.ListOptions{
|
||||
opt := &github.ListOptions{
|
||||
// This is the maximum amount per-page that GitHub allows.
|
||||
PerPage: 100,
|
||||
})
|
||||
return teams, err
|
||||
}
|
||||
var allTeams []*github.Team
|
||||
for {
|
||||
teams, resp, err := github.NewClient(client).Teams.ListTeams(ctx, org, opt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
allTeams = append(allTeams, teams...)
|
||||
if resp.NextPage == 0 {
|
||||
break
|
||||
}
|
||||
opt.Page = resp.NextPage
|
||||
}
|
||||
return allTeams, nil
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue