From eb0f166f507c014aa808ac9f5576689e6bf66916 Mon Sep 17 00:00:00 2001
From: Morgan Bazalgette <git@howl.moe>
Date: Fri, 12 Jan 2018 15:37:30 +0100
Subject: [PATCH] Address issues pointed out by @lunny in #3339 (#3352)

---
 routers/org/org.go | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/routers/org/org.go b/routers/org/org.go
index 665d1a71fc..bb7540277c 100644
--- a/routers/org/org.go
+++ b/routers/org/org.go
@@ -22,10 +22,6 @@ const (
 
 // Create render the page for create organization
 func Create(ctx *context.Context) {
-	if !ctx.User.CanCreateOrganization() {
-		ctx.NotFound("CanCreateOrganization", nil)
-	}
-
 	ctx.Data["Title"] = ctx.Tr("new_org")
 	if !ctx.User.CanCreateOrganization() {
 		ctx.ServerError("Not allowed", errors.New(ctx.Tr("org.form.create_org_not_allowed")))
@@ -36,12 +32,13 @@ func Create(ctx *context.Context) {
 
 // CreatePost response for create organization
 func CreatePost(ctx *context.Context, form auth.CreateOrgForm) {
-	if !ctx.User.CanCreateOrganization() {
-		ctx.NotFound("CanCreateOrganization", nil)
-	}
-
 	ctx.Data["Title"] = ctx.Tr("new_org")
 
+	if !ctx.User.CanCreateOrganization() {
+		ctx.ServerError("Not allowed", errors.New(ctx.Tr("org.form.create_org_not_allowed")))
+		return
+	}
+
 	if ctx.HasError() {
 		ctx.HTML(200, tplCreateOrg)
 		return