FEATURE: Optionally skip using full_name when suggesting usernames (#16592)

This commit introduces a new site setting: `use_name_for_username_suggestions` (default true)

Admins can disable it if they want to stop using Name values when generating usernames for users. This can be useful if you want to keep real names private-by-default or, when used in conjunction with the `use_email_for_username_and_name_suggestions` setting, you would prefer to use email-based username suggestions.
This commit is contained in:
David Taylor
2022-04-29 14:00:13 +01:00
committed by GitHub
parent 14f61c5784
commit 0f772bdf5b
6 changed files with 34 additions and 2 deletions
+14
View File
@@ -450,6 +450,20 @@ describe DiscourseConnect do
expect(user.username).to eq sso.name
end
it "stops using name as a source for username suggestions when disabled" do
SiteSetting.use_name_for_username_suggestions = false
sso = new_discourse_sso
sso.external_id = "100"
sso.username = nil
sso.name = "John Smith"
sso.email = "mail@mail.com"
user = sso.lookup_or_create_user(ip_address)
expect(user.username).to eq "user"
end
it "doesn't use email as a source for username suggestions by default" do
sso = new_discourse_sso
sso.external_id = "100"