ensure usernames do not keep cycling

This commit is contained in:
Sam 2015-03-27 10:04:16 +11:00
parent 94fceaf517
commit 0c287d7d6b
2 changed files with 5 additions and 1 deletions

View File

@ -114,7 +114,9 @@ class DiscourseSingleSignOn < SingleSignOn
user.email = email
end
if SiteSetting.sso_overrides_username && user.username != username
if SiteSetting.sso_overrides_username &&
user.username != username &&
user.username != UserNameSuggester.fix_username(username || name || email)
user.username = UserNameSuggester.suggest(username || name || email)
end

View File

@ -88,7 +88,9 @@ describe DiscourseSingleSignOn do
sso.lookup_or_create_user(ip_address)
admin.reload
expect(admin.email).to eq("test@bob.com")
expect(admin.username).to eq "bob_the_admin"
end
it "can fill in data on way back" do