1
1
mirror of https://github.com/go-gitea/gitea synced 2025-09-28 03:28:13 +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:
Morgan Bazalgette
2018-01-10 22:34:17 +01:00
committed by Lauris BH
parent 45c264f681
commit 65861900cd
48 changed files with 622 additions and 610 deletions

View File

@@ -30,7 +30,7 @@ func SettingsOpenID(ctx *context.Context) {
openid, err := models.GetUserOpenIDs(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserOpenIDs", err)
ctx.ServerError("GetUserOpenIDs", err)
return
}
ctx.Data["OpenIDs"] = openid
@@ -46,7 +46,7 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) {
if ctx.HasError() {
openid, err := models.GetUserOpenIDs(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserOpenIDs", err)
ctx.ServerError("GetUserOpenIDs", err)
return
}
ctx.Data["OpenIDs"] = openid
@@ -70,7 +70,7 @@ func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) {
oids, err := models.GetUserOpenIDs(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserOpenIDs", err)
ctx.ServerError("GetUserOpenIDs", err)
return
}
ctx.Data["OpenIDs"] = oids
@@ -100,7 +100,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
oids, err := models.GetUserOpenIDs(ctx.User.ID)
if err != nil {
ctx.Handle(500, "GetUserOpenIDs", err)
ctx.ServerError("GetUserOpenIDs", err)
return
}
ctx.Data["OpenIDs"] = oids
@@ -121,7 +121,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsOpenID, &auth.AddOpenIDForm{Openid: id})
return
}
ctx.Handle(500, "AddUserOpenID", err)
ctx.ServerError("AddUserOpenID", err)
return
}
log.Trace("Associated OpenID %s to user %s", id, ctx.User.Name)
@@ -133,7 +133,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
// DeleteOpenID response for delete user's openid
func DeleteOpenID(ctx *context.Context) {
if err := models.DeleteUserOpenID(&models.UserOpenID{ID: ctx.QueryInt64("id"), UID: ctx.User.ID}); err != nil {
ctx.Handle(500, "DeleteUserOpenID", err)
ctx.ServerError("DeleteUserOpenID", err)
return
}
log.Trace("OpenID address deleted: %s", ctx.User.Name)
@@ -147,7 +147,7 @@ func DeleteOpenID(ctx *context.Context) {
// ToggleOpenIDVisibility response for toggle visibility of user's openid
func ToggleOpenIDVisibility(ctx *context.Context) {
if err := models.ToggleUserOpenIDVisibility(ctx.QueryInt64("id")); err != nil {
ctx.Handle(500, "ToggleUserOpenIDVisibility", err)
ctx.ServerError("ToggleUserOpenIDVisibility", err)
return
}