From 3ac1f35349ec7d4d76fdf13ade34307138e5a2a4 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 31 Aug 2021 12:49:02 +0200 Subject: [PATCH] List limited and private orgs if authenticated on API (#16866) (#16879) --- routers/api/v1/admin/org.go | 1 + routers/api/v1/org/org.go | 1 + routers/api/v1/user/user.go | 6 ++---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index 1356276f0..d20c17fed 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -106,6 +106,7 @@ func GetAllOrgs(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ + Actor: ctx.User, Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, ListOptions: listOptions, diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 5c16594f8..860fec77c 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -130,6 +130,7 @@ func GetAll(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) publicOrgs, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ + Actor: ctx.User, ListOptions: listOptions, Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index ac543d597..4ca0fc243 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -56,15 +56,13 @@ func Search(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) - opts := &models.SearchUserOptions{ + users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ Actor: ctx.User, Keyword: strings.Trim(ctx.Query("q"), " "), UID: ctx.QueryInt64("uid"), Type: models.UserTypeIndividual, ListOptions: listOptions, - } - - users, maxResults, err := models.SearchUsers(opts) + }) if err != nil { ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ "ok": false,