mirror of
https://github.com/go-gitea/gitea
synced 2025-08-02 15:48:35 +00:00
Refactor error system (#33610)
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
// RegenerateScratchTwoFactor regenerates the user's 2FA scratch code.
|
||||
func RegenerateScratchTwoFactor(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func RegenerateScratchTwoFactor(ctx *context.Context) {
|
||||
// DisableTwoFactor deletes the user's 2FA settings.
|
||||
func DisableTwoFactor(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ func twofaGenerateSecretAndQr(ctx *context.Context) bool {
|
||||
// EnrollTwoFactor shows the page where the user can enroll into 2FA.
|
||||
func EnrollTwoFactor(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ func EnrollTwoFactor(ctx *context.Context) {
|
||||
// EnrollTwoFactorPost handles enrolling the user into 2FA.
|
||||
func EnrollTwoFactorPost(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageMFA) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ import (
|
||||
// OpenIDPost response for change user's openid
|
||||
func OpenIDPost(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func settingsOpenIDVerify(ctx *context.Context) {
|
||||
// DeleteOpenID response for delete user's openid
|
||||
func DeleteOpenID(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ func DeleteOpenID(ctx *context.Context) {
|
||||
// ToggleOpenIDVisibility response for toggle visibility of user's openid
|
||||
func ToggleOpenIDVisibility(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ const (
|
||||
func Security(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer,
|
||||
setting.UserFeatureManageMFA, setting.UserFeatureManageCredentials) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func Security(ctx *context.Context) {
|
||||
// DeleteAccountLink delete a single account link
|
||||
func DeleteAccountLink(ctx *context.Context) {
|
||||
if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureManageCredentials) {
|
||||
ctx.Error(http.StatusNotFound)
|
||||
ctx.HTTPError(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user