diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-11-26 13:55:06 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-26 21:55:06 +0000 |
commit | f49d82309b58a7f4150633be812da499de98da1b (patch) | |
tree | 0b0b3f7e6f23ba399377ef79cdee2a6ed19d369a /services | |
parent | b6ce2d6dc9db16227c523b2d0a39a231e5d38945 (diff) | |
download | gitea-f49d82309b58a7f4150633be812da499de98da1b.tar.gz gitea-f49d82309b58a7f4150633be812da499de98da1b.zip |
Introduce OrgList and add LoadTeams, optimaze Load teams for orgs (#32543)
Diffstat (limited to 'services')
-rw-r--r-- | services/oauth2_provider/access_token.go | 11 |
1 files changed, 6 insertions, 5 deletions
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) } |