mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Handle refactor (#3339)
* Replace all ctx.Handle with ctx.ServerError or ctx.NotFound * Change Handle(403) to NotFound, avoid using macaron's NotFound
This commit is contained in:
committed by
Lauris BH
parent
45c264f681
commit
65861900cd
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user