mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-22 08:55:41 +01:00
Fix CanUserSeeAllTeams to handle Site Admins correctly
This commit is contained in:
parent
824e52cb26
commit
f5773c16e8
@ -598,8 +598,11 @@ func getUserTeamIDsQueryBuilder(orgID, userID int64) *builder.Builder {
|
||||
}
|
||||
|
||||
// CanUserSeeAllTeams returns true if user can see all teams in organization
|
||||
func (org *Organization) CanUserSeeAllTeams(ctx context.Context, userID int64) (bool, error) {
|
||||
isOwner, err := org.IsOwnedBy(ctx, userID)
|
||||
func (org *Organization) CanUserSeeAllTeams(ctx context.Context, user *user_model.User) (bool, error) {
|
||||
if user.IsAdmin {
|
||||
return true, nil
|
||||
}
|
||||
isOwner, err := org.IsOwnedBy(ctx, user.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -607,7 +610,7 @@ func (org *Organization) CanUserSeeAllTeams(ctx context.Context, userID int64) (
|
||||
return true, nil
|
||||
}
|
||||
|
||||
teams, err := org.GetUserTeams(ctx, userID)
|
||||
teams, err := org.GetUserTeams(ctx, user.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ func Teams(ctx *context.Context) {
|
||||
},
|
||||
}
|
||||
|
||||
canSeeAllTeams, err := ctx.Org.Organization.CanUserSeeAllTeams(ctx, ctx.Doer.ID)
|
||||
canSeeAllTeams, err := ctx.Org.Organization.CanUserSeeAllTeams(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("CanUserSeeAllTeams", err)
|
||||
return
|
||||
|
||||
@ -173,7 +173,7 @@ func OrgAssignment(orgAssignmentOpts OrgAssignmentOptions) func(ctx *Context) {
|
||||
|
||||
// Team.
|
||||
if ctx.Org.IsMember {
|
||||
shouldSeeAllTeams, err := org.CanUserSeeAllTeams(ctx, ctx.Doer.ID)
|
||||
shouldSeeAllTeams, err := org.CanUserSeeAllTeams(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.ServerError("CanUserSeeAllTeams", err)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user