FEATURE: Add fallback to suggested value when auth_overrides_username (#16612)

If the identity provider does not provide a precise username value, then we should use our UserNameSuggester to generate one and use it for the override. This makes the override consistent with initial account creation.
This commit is contained in:
David Taylor
2022-05-04 11:22:09 +01:00
committed by GitHub
parent a35837dc0b
commit 485fc4636a
2 changed files with 12 additions and 3 deletions

View File

@ -51,6 +51,15 @@ describe Auth::Result do
expect(user.name).to eq(new_name)
end
it "overrides username with suggested value if missing" do
SiteSetting.auth_overrides_username = true
result.username = nil
result.apply_user_attributes!
expect(user.username).to eq("New_Name")
end
it "updates the user's email if currently invalid" do
user.update!(email: "someemail@discourse.org")
expect { result.apply_user_attributes! }.not_to change { user.email }