0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-04-04 14:36:16 +02:00

fix: update CanAccessAtLevel func

ensure that public groups can always be accessed if requested level == read
This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2025-12-20 15:22:33 -05:00
parent 436b04fe0e
commit b0257d1468
No known key found for this signature in database
GPG Key ID: 924A5F6AF051E87C

View File

@ -137,7 +137,11 @@ func (g *Group) CanAccess(ctx context.Context, user *user_model.User) (bool, err
}
func (g *Group) CanAccessAtLevel(ctx context.Context, user *user_model.User, level perm.AccessMode) (bool, error) {
return db.GetEngine(ctx).Where(AccessibleGroupCondition(user, unit.TypeInvalid, level).And(builder.Eq{"`repo_group`.id": g.ID})).Exist(&Group{})
orCond := builder.Or(AccessibleGroupCondition(user, unit.TypeInvalid, level))
if level == perm.AccessModeRead {
orCond = orCond.Or(builder.Eq{"`repo_group`.visibility": structs.VisibleTypePublic})
}
return db.GetEngine(ctx).Table(g.TableName()).Where(orCond.And(builder.Eq{"`repo_group`.id": g.ID})).Exist()
}
func (g *Group) IsOwnedBy(ctx context.Context, userID int64) (bool, error) {