diff --git a/modules/context/org.go b/modules/context/org.go index 53c46d6b9eb5c..2d7cf5185c506 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -24,6 +24,7 @@ type Organization struct { Organization *organization.Organization OrgLink string CanCreateOrgRepo bool + PublicMemberOnly bool // Only display public members Team *organization.Team Teams []*organization.Team @@ -173,11 +174,11 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Data["OrgLink"] = ctx.Org.OrgLink // Member + ctx.Org.PublicMemberOnly = ctx.Doer == nil || !ctx.Org.IsMember && !ctx.Doer.IsAdmin opts := &organization.FindOrgMembersOpts{ OrgID: org.ID, - PublicOnly: true, + PublicOnly: ctx.Org.PublicMemberOnly, } - opts.PublicOnly = ctx.Doer == nil || !ctx.Org.IsMember && !ctx.Doer.IsAdmin ctx.Data["NumMembers"], err = organization.CountOrgMembers(opts) if err != nil { ctx.ServerError("CountOrgMembers", err) diff --git a/routers/web/org/home.go b/routers/web/org/home.go index ca86317c04b67..1261922ba6f1d 100644 --- a/routers/web/org/home.go +++ b/routers/web/org/home.go @@ -119,14 +119,9 @@ func Home(ctx *context.Context) { opts := &organization.FindOrgMembersOpts{ OrgID: org.ID, - PublicOnly: true, + PublicOnly: ctx.Org.PublicMemberOnly, ListOptions: db.ListOptions{Page: 1, PageSize: 25}, } - - if ctx.Doer != nil { - opts.PublicOnly = !ctx.Org.IsMember && !ctx.Doer.IsAdmin - } - members, _, err := organization.FindOrgMembers(opts) if err != nil { ctx.ServerError("FindOrgMembers", err)