aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/web.go10
-rw-r--r--conf/app.ini2
-rw-r--r--gogs.go2
-rw-r--r--models/user.go4
-rw-r--r--modules/setting/setting.go7
-rw-r--r--templates/.VERSION2
-rw-r--r--templates/base/head.tmpl2
7 files changed, 25 insertions, 4 deletions
diff --git a/cmd/web.go b/cmd/web.go
index fa338376..9ed63289 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -362,8 +362,14 @@ func runWeb(ctx *cli.Context) error {
// ***** START: Organization *****
m.Group("/org", func() {
- m.Get("/create", org.Create)
- m.Post("/create", bindIgnErr(auth.CreateOrgForm{}), org.CreatePost)
+ m.Group("", func() {
+ m.Get("/create", org.Create)
+ m.Post("/create", bindIgnErr(auth.CreateOrgForm{}), org.CreatePost)
+ }, func(ctx *context.Context) {
+ if !ctx.User.CanCreateOrganization() {
+ ctx.NotFound()
+ }
+ })
m.Group("/:org", func() {
m.Get("/dashboard", user.Dashboard)
diff --git a/conf/app.ini b/conf/app.ini
index 6e4e7a08..27773a8a 100644
--- a/conf/app.ini
+++ b/conf/app.ini
@@ -171,6 +171,8 @@ SSL_MODE = disable
PATH = data/gogs.db
[admin]
+; Disable regular (non-admin) users to create organizations
+DISABLE_REGULAR_ORG_CREATION = false
[security]
INSTALL_LOCK = false
diff --git a/gogs.go b/gogs.go
index 5ca4b68c..0c5b344f 100644
--- a/gogs.go
+++ b/gogs.go
@@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.9.139.0210"
+const APP_VER = "0.9.140.0210"
func init() {
setting.AppVer = APP_VER
diff --git a/models/user.go b/models/user.go
index 4b44a513..6a7365ab 100644
--- a/models/user.go
+++ b/models/user.go
@@ -170,6 +170,10 @@ func (u *User) CanCreateRepo() bool {
return u.NumRepos < u.MaxRepoCreation
}
+func (u *User) CanCreateOrganization() bool {
+ return !setting.Admin.DisableRegularOrgCreation || u.IsAdmin
+}
+
// CanEditGitHook returns true if user can edit Git hooks.
func (u *User) CanEditGitHook() bool {
return u.IsAdmin || u.AllowGitHook
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index ac4a893b..8f6885c1 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -170,6 +170,11 @@ var (
FileExtensions []string
}
+ // Admin settings
+ Admin struct {
+ DisableRegularOrgCreation bool
+ }
+
// Picture settings
AvatarUploadPath string
GravatarSource string
@@ -568,6 +573,8 @@ func NewContext() {
log.Fatal(4, "Fail to map UI settings: %v", err)
} else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
log.Fatal(4, "Fail to map Markdown settings: %v", err)
+ } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
+ log.Fatal(4, "Fail to map Admin settings: %v", err)
} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
log.Fatal(4, "Fail to map Cron settings: %v", err)
} else if err = Cfg.Section("git").MapTo(&Git); err != nil {
diff --git a/templates/.VERSION b/templates/.VERSION
index 694d35dd..48bfda0f 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.9.139.0210 \ No newline at end of file
+0.9.140.0210 \ No newline at end of file
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index ae54e1e7..50a8283f 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -93,9 +93,11 @@
<a class="item" href="{{AppSubUrl}}/repo/migrate">
<i class="octicon octicon-repo-clone"></i> {{.i18n.Tr "new_migrate"}}
</a>
+ {{if .SignedUser.CanCreateOrganization}}
<a class="item" href="{{AppSubUrl}}/org/create">
<i class="octicon octicon-organization"></i> {{.i18n.Tr "new_org"}}
</a>
+ {{end}}
</div><!-- end content create new menu -->
</div><!-- end dropdown menu create new -->