[API] List limited and private orgs if authentificated (#16866)

* fix bug #16785 and similar

* code format

* CI.restart()
tokarchuk/v1.17
6543 3 years ago committed by GitHub
parent 06b9d553bc
commit 73394f435c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      routers/api/v1/admin/org.go
  2. 1
      routers/api/v1/org/org.go
  3. 6
      routers/api/v1/user/user.go

@ -105,6 +105,7 @@ func GetAllOrgs(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx) listOptions := utils.GetListOptions(ctx)
users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{
Actor: ctx.User,
Type: models.UserTypeOrganization, Type: models.UserTypeOrganization,
OrderBy: models.SearchOrderByAlphabetically, OrderBy: models.SearchOrderByAlphabetically,
ListOptions: listOptions, ListOptions: listOptions,

@ -128,6 +128,7 @@ func GetAll(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx) listOptions := utils.GetListOptions(ctx)
publicOrgs, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ publicOrgs, maxResults, err := models.SearchUsers(&models.SearchUserOptions{
Actor: ctx.User,
ListOptions: listOptions, ListOptions: listOptions,
Type: models.UserTypeOrganization, Type: models.UserTypeOrganization,
OrderBy: models.SearchOrderByAlphabetically, OrderBy: models.SearchOrderByAlphabetically,

@ -54,15 +54,13 @@ func Search(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx) listOptions := utils.GetListOptions(ctx)
opts := &models.SearchUserOptions{ users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{
Actor: ctx.User, Actor: ctx.User,
Keyword: ctx.FormTrim("q"), Keyword: ctx.FormTrim("q"),
UID: ctx.FormInt64("uid"), UID: ctx.FormInt64("uid"),
Type: models.UserTypeIndividual, Type: models.UserTypeIndividual,
ListOptions: listOptions, ListOptions: listOptions,
} })
users, maxResults, err := models.SearchUsers(opts)
if err != nil { if err != nil {
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
"ok": false, "ok": false,

Loading…
Cancel
Save