1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00:00

Refactor error system (#33610)

This commit is contained in:
wxiaoguang
2025-02-17 14:13:17 +08:00
committed by GitHub
parent 69de5a65c2
commit f35850f48e
184 changed files with 2100 additions and 2106 deletions

View File

@@ -25,7 +25,7 @@ import (
// WebAuthnRegister initializes the webauthn registration procedure
func WebAuthnRegister(ctx *context.Context) {
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
@@ -41,7 +41,7 @@ func WebAuthnRegister(ctx *context.Context) {
return
}
if cred != nil {
ctx.Error(http.StatusConflict, "Name already taken")
ctx.HTTPError(http.StatusConflict, "Name already taken")
return
}
@@ -72,7 +72,7 @@ func WebAuthnRegister(ctx *context.Context) {
// WebauthnRegisterPost receives the response of the security key
func WebauthnRegisterPost(ctx *context.Context) {
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}
@@ -109,7 +109,7 @@ func WebauthnRegisterPost(ctx *context.Context) {
return
}
if dbCred != nil {
ctx.Error(http.StatusConflict, "Name already taken")
ctx.HTTPError(http.StatusConflict, "Name already taken")
return
}
@@ -127,7 +127,7 @@ func WebauthnRegisterPost(ctx *context.Context) {
// WebauthnDelete deletes an security key by id
func WebauthnDelete(ctx *context.Context) {
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
ctx.Error(http.StatusNotFound)
ctx.HTTPError(http.StatusNotFound)
return
}