summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Olheiser <42128690+jolheiser@users.noreply.github.com>2019-02-21 14:42:54 -0600
committertechknowlogick <matti@mdranta.net>2019-02-21 15:42:54 -0500
commit994b1be9d12cb5c100ab15091bf5e5856aa38ad3 (patch)
treebd55e40b285098f9335ac16430622e49b1cca60f
parent477ef462510d69a8a31e008fb6e64059dc6cc148 (diff)
downloadgitea-994b1be9d12cb5c100ab15091bf5e5856aa38ad3.tar.gz
gitea-994b1be9d12cb5c100ab15091bf5e5856aa38ad3.zip
Admins can now do unlimited page size user search (listAllUsers & listAllOrgs) (#6143)
Non-admins will default to 10 page size
-rw-r--r--models/user.go3
-rw-r--r--routers/api/v1/user/user.go2
2 files changed, 4 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go
index 3fb1c3b59e..d01a29c894 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1433,6 +1433,9 @@ func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error) {
if opts.PageSize > 0 {
sess = sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
}
+ if opts.PageSize == -1 {
+ opts.PageSize = int(count)
+ }
users = make([]*User, 0, opts.PageSize)
return users, count, sess.OrderBy(opts.OrderBy.String()).Find(&users)
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index f76b443661..40d1b76805 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -55,7 +55,7 @@ func Search(ctx *context.APIContext) {
Type: models.UserTypeIndividual,
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
}
- if opts.PageSize == 0 {
+ if opts.PageSize <= 0 {
opts.PageSize = 10
}