fix: allow clearing the full name in profile settings (#40186) (#40191)

backport #40186

Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
wxiaoguangandsilverwind authored and GitHub committed 2026-11-04 20:33:38 +00:00
1 parent 4f536f1513
commit b9a99f0f3e
2 files changed
+6 -6

No files matched your search

+4 -4
View File
@@ -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 {
+2 -2
View File
@@ -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)"`