2
0

fix(org): handle anonymous users in repo count filtering
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m58s
Build and Release / Unit Tests (push) Successful in 6m12s
Build and Release / Lint (push) Successful in 6m21s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Successful in 3m23s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Successful in 9h3m51s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Successful in 8m1s
Build and Release / Build Binaries (arm64, darwin, macos) (push) Failing after 12m57s
Build and Release / Build Binary (linux/arm64) (push) Has been cancelled

Set Private flag based on whether actor is present. When actor is nil (anonymous), Private must be false so SearchRepositoryCondition correctly filters to public repos only. Fixes repo count visibility for unauthenticated users.
This commit is contained in:
2026-03-04 09:13:55 -05:00
parent 112130747c
commit 8cf6c08841
2 changed files with 5 additions and 3 deletions

View File

@@ -2198,7 +2198,7 @@ func toolListRepos(ctx *context_service.APIContext, args map[string]any) (any, e
},
Actor: ctx.Doer,
OwnerID: ownerUser.ID,
Private: true,
Private: ctx.Doer != nil,
OrderBy: db.SearchOrderByAlphabetically,
Archived: optional.Some(false),
})

View File

@@ -62,11 +62,13 @@ func GetOrgOverviewStats(ctx context.Context, orgID int64, actor *user_model.Use
stats.TotalMembers = memberCount
stats.TotalTeams = teamCount
// Repo count - use SearchRepository with Actor for permission filtering
// Repo count - use SearchRepository with Actor for permission filtering.
// Private=true only works when Actor is set; for anonymous users we must
// use Private=false so SearchRepositoryCondition filters to public repos only.
_, stats.TotalRepos, err = repo_model.SearchRepository(ctx, repo_model.SearchRepoOptions{
Actor: actor,
OwnerID: orgID,
Private: true,
Private: actor != nil,
})
if err != nil {
return nil, err