@@ -1097,6 +1097,7 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
// Organizations | // Organizations | ||||
m.Get("/user/orgs", reqToken(), org.ListMyOrgs) | m.Get("/user/orgs", reqToken(), org.ListMyOrgs) | ||||
m.Get("/user/owners", reqToken(), org.GetMyOwners) | |||||
m.Get("/users/:username/orgs", org.ListUserOrgs) | m.Get("/users/:username/orgs", org.ListUserOrgs) | ||||
m.Post("/orgs", reqToken(), bind(api.CreateOrgOption{}), org.Create) | m.Post("/orgs", reqToken(), bind(api.CreateOrgOption{}), org.Create) | ||||
m.Get("/orgs", org.GetAll) | m.Get("/orgs", org.GetAll) | ||||
@@ -6,6 +6,7 @@ | |||||
package org | package org | ||||
import ( | import ( | ||||
"code.gitea.io/gitea/routers/response" | |||||
"net/http" | "net/http" | ||||
"code.gitea.io/gitea/models" | "code.gitea.io/gitea/models" | ||||
@@ -278,3 +279,29 @@ func Delete(ctx *context.APIContext) { | |||||
} | } | ||||
ctx.Status(http.StatusNoContent) | ctx.Status(http.StatusNoContent) | ||||
} | } | ||||
func GetMyOwners(ctx *context.APIContext) { | |||||
result := make([]*models.User4Front, 0) | |||||
result = append(result, ctx.User.ToFrontFormat()) | |||||
orgs, err := models.GetOrgsCanCreateRepoByUserID(ctx.User.ID) | |||||
if err != nil { | |||||
ctx.JSON(http.StatusOK, response.ResponseError(err)) | |||||
return | |||||
} | |||||
if !ctx.User.IsAdmin { | |||||
orgsAvailable := []*models.User{} | |||||
for i := 0; i < len(orgs); i++ { | |||||
if orgs[i].CanCreateRepo() { | |||||
orgsAvailable = append(orgsAvailable, orgs[i]) | |||||
} | |||||
} | |||||
orgs = orgsAvailable | |||||
} | |||||
for _, o := range orgs { | |||||
result = append(result, o.ToFrontFormat()) | |||||
} | |||||
ctx.JSON(http.StatusOK, response.SuccessWithData(result)) | |||||
} |
@@ -29,7 +29,12 @@ func parseOpenIUrl(u string) (string, string) { | |||||
if err != nil { | if err != nil { | ||||
return "", "" | return "", "" | ||||
} | } | ||||
if !strings.Contains(setting.AppURL, url.Host) { | |||||
appUrl, err := url.Parse(setting.AppURL) | |||||
if err != nil { | |||||
return "", "" | |||||
} | |||||
if appUrl.Host != url.Host { | |||||
return "", "" | return "", "" | ||||
} | } | ||||