From df35049196de70b5d0855e9777456e3f6ffd7772 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 26 Feb 2022 21:45:34 +0000 Subject: [PATCH] Allow adminstrator teams members to see other teams (#18918) (#18919) Allow adminstrator teams members to see other teams (#18918) --- modules/context/org.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/context/org.go b/modules/context/org.go index 585a5fd762..824f22b2f3 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -129,7 +129,23 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { // Team. if ctx.Org.IsMember { + shouldSeeAllTeams := false if ctx.Org.IsOwner { + shouldSeeAllTeams = true + } else { + teams, err := org.GetUserTeams(ctx.User.ID) + if err != nil { + ctx.ServerError("GetUserTeams", err) + return + } + for _, team := range teams { + if team.IncludesAllRepositories && team.AccessMode >= perm.AccessModeAdmin { + shouldSeeAllTeams = true + break + } + } + } + if shouldSeeAllTeams { ctx.Org.Teams, err = org.LoadTeams() if err != nil { ctx.ServerError("LoadTeams", err)