forked from kevadesu/forgejo
fix: don't show private forks in forks list
- If a repository is forked to a private or limited user/organization, the fork should not be visible in the list of forks depending on the doer requesting the list of forks. - Added integration testing for web and API route.
This commit is contained in:
parent
3e3ef76808
commit
061abe6004
5 changed files with 88 additions and 11 deletions
|
@ -1232,11 +1232,8 @@ func Forks(ctx *context.Context) {
|
|||
page = 1
|
||||
}
|
||||
|
||||
pager := context.NewPagination(ctx.Repo.Repository.NumForks, setting.MaxForksPerPage, page, 5)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
forks, err := repo_model.GetForks(ctx, ctx.Repo.Repository, db.ListOptions{
|
||||
Page: pager.Paginater.Current(),
|
||||
forks, total, err := repo_model.GetForks(ctx, ctx.Repo.Repository, ctx.Doer, db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: setting.MaxForksPerPage,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1244,6 +1241,9 @@ func Forks(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
pager := context.NewPagination(int(total), setting.MaxForksPerPage, page, 5)
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
for _, fork := range forks {
|
||||
if err = fork.LoadOwner(ctx); err != nil {
|
||||
ctx.ServerError("LoadOwner", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue