summaryrefslogtreecommitdiffstats
path: root/routers/home.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-26 13:59:31 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-26 13:59:31 +0800
commit95574a36400e7714d78e7016c8a14dc0b60311b1 (patch)
tree6c524878571dbf30c7b189273bdcb9b0d28dfe22 /routers/home.go
parent831ff417547f0f0a26c75288bdb790ea40087c0c (diff)
downloadgitea-95574a36400e7714d78e7016c8a14dc0b60311b1.tar.gz
gitea-95574a36400e7714d78e7016c8a14dc0b60311b1.zip
fix: Admin can see all private repositories on Explore page. (#1026)
* fix: Admin can see all private repositories on Explore page. * refactor: fix session
Diffstat (limited to 'routers/home.go')
-rw-r--r--routers/home.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/routers/home.go b/routers/home.go
index 3de32b52e7..9fa565b217 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -53,8 +53,7 @@ func Home(ctx *context.Context) {
// RepoSearchOptions when calling search repositories
type RepoSearchOptions struct {
- Counter func(bool) int64
- Ranger func(*models.SearchRepoOptions) (models.RepositoryList, error)
+ Ranger func(*models.SearchRepoOptions) (models.RepositoryList, int64, error)
Searcher *models.User
Private bool
PageSize int
@@ -101,17 +100,17 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
- repos, err = opts.Ranger(&models.SearchRepoOptions{
+ repos, count, err = opts.Ranger(&models.SearchRepoOptions{
Page: page,
PageSize: opts.PageSize,
Searcher: ctx.User,
OrderBy: orderBy,
+ Private: opts.Private,
})
if err != nil {
ctx.Handle(500, "opts.Ranger", err)
return
}
- count = opts.Counter(opts.Private)
} else {
if isKeywordValid(keyword) {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
@@ -143,10 +142,10 @@ func ExploreRepos(ctx *context.Context) {
ctx.Data["PageIsExploreRepositories"] = true
RenderRepoSearch(ctx, &RepoSearchOptions{
- Counter: models.CountRepositories,
Ranger: models.GetRecentUpdatedRepositories,
PageSize: setting.UI.ExplorePagingNum,
Searcher: ctx.User,
+ Private: ctx.User != nil && ctx.User.IsAdmin,
TplName: tplExploreRepos,
})
}
@@ -175,7 +174,6 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
)
ctx.Data["SortType"] = ctx.Query("sort")
- //OrderBy: "id ASC",
switch ctx.Query("sort") {
case "oldest":
orderBy = "id ASC"
@@ -193,7 +191,8 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
keyword := strings.Trim(ctx.Query("q"), " ")
if len(keyword) == 0 {
- users, err = opts.Ranger(&models.SearchUserOptions{OrderBy: orderBy,
+ users, err = opts.Ranger(&models.SearchUserOptions{
+ OrderBy: orderBy,
Page: page,
PageSize: opts.PageSize,
})