]> source.dussan.org Git - gitea.git/commitdiff
List limited and private orgs if authenticated on API (#16866) (#16879)
author6543 <6543@obermui.de>
Tue, 31 Aug 2021 10:49:02 +0000 (12:49 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Aug 2021 10:49:02 +0000 (12:49 +0200)
routers/api/v1/admin/org.go
routers/api/v1/org/org.go
routers/api/v1/user/user.go

index 1356276f07f4fb38bd931e21bdc90138e4407799..d20c17fed302c9d3296da8c1a9845decad633e2c 100644 (file)
@@ -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,
index 5c16594f89d1813332ce3bf6b8acd74f7c629d3a..860fec77cdd556290acffc13f5dbed64c8c67eeb 100644 (file)
@@ -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,
index ac543d597d7e8bef89e28edcd180803d0a45e19d..4ca0fc24395e82127d6b9174269c214886735082 100644 (file)
@@ -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,