Skip to content

Commit a195c3f

Browse files
appleboylunny
authored andcommitted
fix: Admin can also search private user repository. (#869)
1 parent 181c8d9 commit a195c3f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

routers/user/profile.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ func Profile(ctx *context.Context) {
130130
err error
131131
orderBy string
132132
)
133+
134+
ctx.Data["SortType"] = ctx.Query("sort")
133135
switch ctx.Query("sort") {
134136
case "newest":
135137
orderBy = "created_unix DESC"
@@ -144,10 +146,17 @@ func Profile(ctx *context.Context) {
144146
case "alphabetically":
145147
orderBy = "name ASC"
146148
default:
149+
ctx.Data["SortType"] = "recentupdate"
147150
orderBy = "updated_unix DESC"
148151
}
149152

153+
// set default sort value if sort is empty.
154+
if ctx.Query("sort") == "" {
155+
ctx.Data["SortType"] = "recentupdate"
156+
}
157+
150158
keyword := ctx.Query("q")
159+
ctx.Data["Keyword"] = keyword
151160
if len(keyword) == 0 {
152161
var total int
153162
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy)
@@ -175,7 +184,7 @@ func Profile(ctx *context.Context) {
175184
Keyword: keyword,
176185
OwnerID: ctxUser.ID,
177186
OrderBy: orderBy,
178-
Private: ctx.IsSigned && ctx.User.ID == ctxUser.ID,
187+
Private: showPrivate,
179188
Page: page,
180189
PageSize: setting.UI.User.RepoPagingNum,
181190
})
@@ -188,15 +197,6 @@ func Profile(ctx *context.Context) {
188197
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5)
189198
ctx.Data["Total"] = count
190199
}
191-
192-
// set default sort value.
193-
if ctx.Query("sort") == "" {
194-
ctx.Data["SortType"] = "recentupdate"
195-
} else {
196-
ctx.Data["SortType"] = ctx.Query("sort")
197-
}
198-
199-
ctx.Data["Keyword"] = keyword
200200
}
201201

202202
ctx.HTML(200, tplProfile)

0 commit comments

Comments
 (0)