diff options
author | Morgan Bazalgette <git@howl.moe> | 2018-01-10 22:34:17 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2018-01-10 23:34:17 +0200 |
commit | 65861900cda3bb6d9e2aa80b808b0000383c04b3 (patch) | |
tree | 8569d93b6ef092b30b35a4d4da906c6b6950e2ee /routers/org/org.go | |
parent | 45c264f681e3f7e1a22a191029836a690959aac3 (diff) | |
download | gitea-65861900cda3bb6d9e2aa80b808b0000383c04b3.tar.gz gitea-65861900cda3bb6d9e2aa80b808b0000383c04b3.zip |
Handle refactor (#3339)
* Replace all ctx.Handle with ctx.ServerError or ctx.NotFound
* Change Handle(403) to NotFound, avoid using macaron's NotFound
Diffstat (limited to 'routers/org/org.go')
-rw-r--r-- | routers/org/org.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/routers/org/org.go b/routers/org/org.go index d0988bfcf5..665d1a71fc 100644 --- a/routers/org/org.go +++ b/routers/org/org.go @@ -22,9 +22,13 @@ 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.Handle(500, "Not allowed", errors.New(ctx.Tr("org.form.create_org_not_allowed"))) + ctx.ServerError("Not allowed", errors.New(ctx.Tr("org.form.create_org_not_allowed"))) return } ctx.HTML(200, tplCreateOrg) @@ -32,6 +36,10 @@ 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.HasError() { @@ -57,7 +65,7 @@ func CreatePost(ctx *context.Context, form auth.CreateOrgForm) { case models.IsErrUserNotAllowedCreateOrg(err): ctx.RenderWithErr(ctx.Tr("org.form.create_org_not_allowed"), tplCreateOrg, &form) default: - ctx.Handle(500, "CreateOrganization", err) + ctx.ServerError("CreateOrganization", err) } return } |