summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2018-07-05 02:51:02 +0300
committerJonas Franz <info@jonasfranz.software>2018-07-05 01:51:02 +0200
commit69e2ab161109eef667cd22a96711e4a8ee9d01d2 (patch)
treec69499946dfb2e61390fb1c57a4afe42d9c362f0 /routers
parent4eae810d63cb48977d7c0b96c90877592ec3d7b2 (diff)
downloadgitea-69e2ab161109eef667cd22a96711e4a8ee9d01d2.tar.gz
gitea-69e2ab161109eef667cd22a96711e4a8ee9d01d2.zip
Allow administrator to create repository for any organization (#4368)
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/repo.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index c6c5d4aec3..044b1e9c18 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -257,13 +257,15 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
return
}
- isOwner, err := org.IsOwnedBy(ctx.User.ID)
- if err != nil {
- ctx.ServerError("IsOwnedBy", err)
- return
- } else if !isOwner {
- ctx.Error(403, "", "Given user is not owner of organization.")
- return
+ if !ctx.User.IsAdmin {
+ isOwner, err := org.IsOwnedBy(ctx.User.ID)
+ if err != nil {
+ ctx.ServerError("IsOwnedBy", err)
+ return
+ } else if !isOwner {
+ ctx.Error(403, "", "Given user is not owner of organization.")
+ return
+ }
}
CreateUserRepo(ctx, org, opt)
}