From f49d82309b58a7f4150633be812da499de98da1b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 26 Nov 2024 13:55:06 -0800 Subject: Introduce OrgList and add LoadTeams, optimaze Load teams for orgs (#32543) --- services/oauth2_provider/access_token.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'services') diff --git a/services/oauth2_provider/access_token.go b/services/oauth2_provider/access_token.go index 77ddce0534..5cb6fb64c5 100644 --- a/services/oauth2_provider/access_token.go +++ b/services/oauth2_provider/access_token.go @@ -241,14 +241,15 @@ func GetOAuthGroupsForUser(ctx context.Context, user *user_model.User, onlyPubli return nil, fmt.Errorf("GetUserOrgList: %w", err) } + orgTeams, err := org_model.OrgList(orgs).LoadTeams(ctx) + if err != nil { + return nil, fmt.Errorf("LoadTeams: %w", err) + } + var groups []string for _, org := range orgs { groups = append(groups, org.Name) - teams, err := org.LoadTeams(ctx) - if err != nil { - return nil, fmt.Errorf("LoadTeams: %w", err) - } - for _, team := range teams { + for _, team := range orgTeams[org.ID] { if team.IsMember(ctx, user.ID) { groups = append(groups, org.Name+":"+team.LowerName) } -- cgit v1.2.3