summaryrefslogtreecommitdiffstats
path: root/routers/repo/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r--routers/repo/repo.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 6cb6c0660e..54e5fcfb20 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -37,11 +37,23 @@ func Create(ctx *middleware.Context) {
ctx.Data["LanguageIgns"] = models.LanguageIgns
ctx.Data["Licenses"] = models.Licenses
+ ctxUser := ctx.User
+ orgId, _ := base.StrTo(ctx.Query("org")).Int64()
+ if orgId > 0 {
+ org, err := models.GetUserById(orgId)
+ if err != nil && err != models.ErrUserNotExist {
+ ctx.Handle(500, "home.Dashboard(GetUserById)", err)
+ return
+ }
+ ctxUser = org
+ }
+ ctx.Data["ContextUser"] = ctxUser
+
if err := ctx.User.GetOrganizations(); err != nil {
ctx.Handle(500, "home.Dashboard(GetOrganizations)", err)
return
}
- ctx.Data["Orgs"] = ctx.User.Orgs
+ ctx.Data["AllUsers"] = append([]*models.User{ctx.User}, ctx.User.Orgs...)
ctx.HTML(200, CREATE)
}
@@ -76,6 +88,12 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) {
}
return
}
+
+ // Check ownership of organization.
+ if !models.IsOrganizationOwner(u.Id, ctx.User.Id) {
+ ctx.Error(403)
+ return
+ }
}
repo, err := models.CreateRepository(u, form.RepoName, form.Description,