From 994b1be9d12cb5c100ab15091bf5e5856aa38ad3 Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Thu, 21 Feb 2019 14:42:54 -0600 Subject: [PATCH] Admins can now do unlimited page size user search (listAllUsers & listAllOrgs) (#6143) Non-admins will default to 10 page size --- models/user.go | 3 +++ routers/api/v1/user/user.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/models/user.go b/models/user.go index 3fb1c3b59..d01a29c89 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 f76b44366..40d1b7680 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 }