From b67ec01d41ad9d504d80ffb950e161b9ce0841fc Mon Sep 17 00:00:00 2001
From: Unknwon <u@gogs.io>
Date: Fri, 10 Feb 2017 16:41:51 -0500
Subject: Able to disable non-admin to create new organization (#1556)

Add new config option '[admin] DISABLE_REGULAR_ORG_CREATION', by
default it's 'false'.
---
 cmd/web.go | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'cmd')

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)
-- 
cgit v1.2.3