diff --git a/routers/web/user/setting/account.go b/routers/web/user/setting/account.go index 1927efb7fe..a8d270dd32 100644 --- a/routers/web/user/setting/account.go +++ b/routers/web/user/setting/account.go @@ -249,21 +249,13 @@ func DeleteAccount(ctx *context.Context) { if _, _, err := auth.UserSignIn(ctx, ctx.Doer.Name, ctx.FormString("password")); err != nil { switch { case user_model.IsErrUserNotExist(err): - loadAccountData(ctx) - - ctx.RenderWithErrDeprecated(ctx.Tr("form.user_not_exist"), tplSettingsAccount, nil) + ctx.JSONError(ctx.Tr("form.user_not_exist")) case errors.Is(err, smtp.ErrUnsupportedLoginType): - loadAccountData(ctx) - - ctx.RenderWithErrDeprecated(ctx.Tr("form.unsupported_login_type"), tplSettingsAccount, nil) + ctx.JSONError(ctx.Tr("form.unsupported_login_type")) case errors.As(err, &db.ErrUserPasswordNotSet{}): - loadAccountData(ctx) - - ctx.RenderWithErrDeprecated(ctx.Tr("form.unset_password"), tplSettingsAccount, nil) + ctx.JSONError(ctx.Tr("form.unset_password")) case errors.As(err, &db.ErrUserPasswordInvalid{}): - loadAccountData(ctx) - - ctx.RenderWithErrDeprecated(ctx.Tr("form.enterred_invalid_password"), tplSettingsAccount, nil) + ctx.JSONError(ctx.Tr("form.enterred_invalid_password")) default: ctx.ServerError("UserSignIn", err) } diff --git a/routers/web/user/setting/security/webauthn.go b/routers/web/user/setting/security/webauthn.go index a265fcdd10..4db7b47879 100644 --- a/routers/web/user/setting/security/webauthn.go +++ b/routers/web/user/setting/security/webauthn.go @@ -132,8 +132,7 @@ func WebauthnDelete(ctx *context.Context) { return } - form := web.GetForm(ctx).(*forms.WebauthnDeleteForm) - if _, err := auth.DeleteCredential(ctx, form.ID, ctx.Doer.ID); err != nil { + if _, err := auth.DeleteCredential(ctx, ctx.FormInt64("id"), ctx.Doer.ID); err != nil { ctx.ServerError("GetWebAuthnCredentialByID", err) return } diff --git a/routers/web/web.go b/routers/web/web.go index bde886177c..4525516f5a 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -643,7 +643,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) { m.Group("/webauthn", func() { m.Post("/request_register", web.Bind(forms.WebauthnRegistrationForm{}), security.WebAuthnRegister) m.Post("/register", security.WebauthnRegisterPost) - m.Post("/delete", web.Bind(forms.WebauthnDeleteForm{}), security.WebauthnDelete) + m.Post("/delete", security.WebauthnDelete) }) m.Group("/openid", func() { m.Post("", web.Bind(forms.AddOpenIDForm{}), security.OpenIDPost) diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 195c746985..75275fb5c7 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -419,17 +419,6 @@ func (f *WebauthnRegistrationForm) Validate(req *http.Request, errs binding.Erro return middleware.Validate(errs, ctx.Data, f, ctx.Locale) } -// WebauthnDeleteForm for deleting WebAuthn keys -type WebauthnDeleteForm struct { - ID int64 `binding:"Required"` -} - -// Validate validates the fields -func (f *WebauthnDeleteForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { - ctx := context.GetValidateContext(req) - return middleware.Validate(errs, ctx.Data, f, ctx.Locale) -} - // PackageSettingForm form for package settings type PackageSettingForm struct { Action string diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index ac4039e596..c652d9c481 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -34,12 +34,10 @@
{{ctx.Locale.Tr "settings.delete_with_all_comments" .UserDeleteWithCommentsMaxTime}}
{{end}}{{ctx.Locale.Tr "settings.regenerate_scratch_token_desc"}}