1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-09 09:24:25 +00:00

Fix repository list permissions

This commit is contained in:
Lunny Xiao 2024-09-29 20:00:35 -07:00
parent 837526aaf0
commit abe592c6e2
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A

View File

@ -2077,13 +2077,24 @@ func ViewIssue(ctx *context.Context) {
}
if ctx.IsSigned {
forkedRepos, err := repo_model.FindUserOrgForks(ctx, ctx.Repo.Repository.ID, ctx.Doer.ID)
forkedRepos, err := repo_model.GetForksByUserAndOrgs(ctx, ctx.Doer, ctx.Repo.Repository)
if err != nil {
ctx.ServerError("FindUserOrgForks", err)
ctx.ServerError("GetForksByUserAndOrgs", err)
return
}
allowedRepos := make([]*repo_model.Repository, 0, len(forkedRepos)+1)
for _, repo := range append(forkedRepos, ctx.Repo.Repository) {
perm, err := access_model.GetUserRepoPermission(ctx, repo, ctx.Doer)
if err != nil {
ctx.ServerError("GetUserRepoPermission", err)
return
}
if perm.CanWrite(unit.TypeCode) {
allowedRepos = append(allowedRepos, repo)
}
}
ctx.Data["AllowedRepos"] = append(forkedRepos, ctx.Repo.Repository)
ctx.Data["AllowedRepos"] = allowedRepos
devLinks, err := issue_service.FindIssueDevLinksByIssue(ctx, issue)
if err != nil {