From e2f5ca92acc6157121e72527c31966e5f371a628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 9 Jan 2025 19:06:48 -0500 Subject: [PATCH] [models/conds] update some repo conditions to check for access provided via groups --- models/repo/repo_list.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/repo/repo_list.go b/models/repo/repo_list.go index eef4578096..6405af31ff 100644 --- a/models/repo/repo_list.go +++ b/models/repo/repo_list.go @@ -290,9 +290,9 @@ func UserCollaborationRepoCond(idStr string, userID int64) builder.Cond { ) } -// UserOrgTeamRepoCond selects repos that the given user has access to through team membership +// UserOrgTeamRepoCond selects repos that the given user has access to through team membership and/or group permissions func UserOrgTeamRepoCond(idStr string, userID int64) builder.Cond { - return builder.In(idStr, userOrgTeamRepoBuilder(userID)) + return builder.In(idStr, userOrgTeamRepoBuilder(userID), userOrgTeamRepoGroupBuilder(userID)) } // userOrgTeamRepoBuilder returns repo ids where user's teams can access. @@ -326,7 +326,9 @@ func userOrgTeamUnitRepoGroupBuilder(userID int64, unitType unit.Type) *builder. // userOrgTeamUnitRepoCond returns a condition to select repo ids where user's teams can access the special unit. func userOrgTeamUnitRepoCond(idStr string, userID int64, unitType unit.Type) builder.Cond { - return builder.In(idStr, userOrgTeamUnitRepoBuilder(userID, unitType)) + return builder.Or(builder.In( + idStr, userOrgTeamUnitRepoBuilder(userID, unitType)), + builder.In(idStr, userOrgTeamUnitRepoGroupBuilder(userID, unitType))) } // UserOrgUnitRepoCond selects repos that the given user has access to through org and the special unit @@ -334,7 +336,7 @@ func UserOrgUnitRepoCond(idStr string, userID, orgID int64, unitType unit.Type) return builder.In(idStr, userOrgTeamUnitRepoBuilder(userID, unitType). And(builder.Eq{"`team_unit`.org_id": orgID}), - ) + userOrgTeamUnitRepoGroupBuilder(userID, unitType).And(builder.Eq{"`team_unit`.org_id": orgID})) } // ReposAccessibleByGroupTeamBuilder returns repositories that are accessible by a team via group permissions