From b9a99f0f3e08f375fbbb1ef27b5a3410d85594ba Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 4 Nov 2026 20:33:38 +0000 Subject: [PATCH] fix: allow clearing the full name in profile settings (#40186) (#40191) backport #40186 Co-authored-by: silverwind --- routers/web/user/setting/profile.go | 8 ++++---- services/forms/user_form.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 9b7cdb2ea9f..7f982d7c6db 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -68,7 +68,7 @@ func ProfilePost(ctx *context.Context) { if form.Name != "" { if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureChangeUsername) { - ctx.Flash.Error(ctx.Tr("user.form.change_username_disabled")) + ctx.Flash.Error(ctx.Tr("form.change_username_disabled")) ctx.Redirect(setting.AppSubURL + "/user/settings") return } @@ -102,13 +102,13 @@ func ProfilePost(ctx *context.Context) { KeepActivityPrivate: optional.Some(form.KeepActivityPrivate), } - if form.FullName != "" { + if form.FullName != nil { if user_model.IsFeatureDisabledWithLoginType(ctx.Doer, setting.UserFeatureChangeFullName) { - ctx.Flash.Error(ctx.Tr("user.form.change_full_name_disabled")) + ctx.Flash.Error(ctx.Tr("form.change_full_name_disabled")) ctx.Redirect(setting.AppSubURL + "/user/settings") return } - opts.FullName = optional.Some(form.FullName) + opts.FullName = optional.FromPtr(form.FullName) } if err := user_service.UpdateUser(ctx, ctx.Doer, opts); err != nil { diff --git a/services/forms/user_form.go b/services/forms/user_form.go index 5f5eb8ca1f3..dda608f4946 100644 --- a/services/forms/user_form.go +++ b/services/forms/user_form.go @@ -160,8 +160,8 @@ type IntrospectTokenForm struct { // UpdateProfileForm form for updating profile type UpdateProfileForm struct { middleware.FormDefaultValidator - Name string `binding:"Username;MaxSize(40)"` - FullName string `binding:"MaxSize(100)"` + Name string `binding:"Username;MaxSize(40)"` + FullName *string `binding:"MaxSize(100)"` KeepEmailPrivate bool Website string `binding:"ValidSiteUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"`