Skip to content

Commit 91af298

Browse files
committed
Add ExternalUserLockFullName option
1 parent cf52cc9 commit 91af298

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

modules/setting/admin.go

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var Admin struct {
1313
DefaultEmailNotification string
1414
UserDisabledFeatures container.Set[string]
1515
ExternalUserDisableFeatures container.Set[string]
16+
ExternalUserLockFullName bool
1617
}
1718

1819
func loadAdminFrom(rootCfg ConfigProvider) {
@@ -21,6 +22,7 @@ func loadAdminFrom(rootCfg ConfigProvider) {
2122
Admin.DefaultEmailNotification = sec.Key("DEFAULT_EMAIL_NOTIFICATIONS").MustString("enabled")
2223
Admin.UserDisabledFeatures = container.SetOf(sec.Key("USER_DISABLED_FEATURES").Strings(",")...)
2324
Admin.ExternalUserDisableFeatures = container.SetOf(sec.Key("EXTERNAL_USER_DISABLE_FEATURES").Strings(",")...).Union(Admin.UserDisabledFeatures)
25+
Admin.ExternalUserLockFullName = sec.Key("EXTERNAL_USER_LOCK_FULLNAME").MustBool(false)
2426
}
2527

2628
const (

routers/web/user/setting/profile.go

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ func Profile(ctx *context.Context) {
5050

5151
ctx.Data["UserDisabledFeatures"] = user_model.DisabledFeaturesWithLoginType(ctx.Doer)
5252

53+
ctx.Data["ExternalUserLockFullName"] = setting.Admin.ExternalUserLockFullName
54+
5355
ctx.HTML(http.StatusOK, tplSettingsProfile)
5456
}
5557

@@ -99,6 +101,11 @@ func ProfilePost(ctx *context.Context) {
99101
Visibility: optional.Some(form.Visibility),
100102
KeepActivityPrivate: optional.Some(form.KeepActivityPrivate),
101103
}
104+
105+
if !ctx.Doer.IsLocal() && setting.Admin.ExternalUserLockFullName {
106+
opts.FullName = optional.None[string]()
107+
}
108+
102109
if err := user_service.UpdateUser(ctx, ctx.Doer, opts); err != nil {
103110
ctx.ServerError("UpdateUser", err)
104111
return

templates/user/settings/profile.tmpl

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
</div>
2020
<div class="field {{if .Err_FullName}}error{{end}}">
2121
<label for="full_name">{{ctx.Locale.Tr "settings.full_name"}}</label>
22-
<input id="full_name" name="full_name" value="{{.SignedUser.FullName}}" maxlength="100">
22+
<input id="full_name" name="full_name" value="{{.SignedUser.FullName}}" {{if and (not .SignedUser.IsLocal) .ExternalUserLockFullName}}disabled{{end}} maxlength="100">
23+
{{if and (not .SignedUser.IsLocal) .ExternalUserLockFullName}}
24+
<p class="help text blue">{{ctx.Locale.Tr "settings.password_full_name_disabled"}}</p>
25+
{{end}}
2326
</div>
2427
<div class="field {{if .Err_Email}}error{{end}}">
2528
<label>{{ctx.Locale.Tr "email"}}</label>

0 commit comments

Comments
 (0)