Skip to content
Snippets Groups Projects
Unverified Commit 3b5f7440 authored by Andrei Prigorshnev's avatar Andrei Prigorshnev Committed by GitHub
Browse files

FEATURE: when suggesting usernames skip input that consist entirely of disallowed characters (#59)

Starting from https://github.com/discourse/discourse/commit/c2022521906b3c44a8a21e8eb2527c8650e06a18 we can pass to `UsernameSuggester` an array of inputs parameters and it'll be skipping invalid items and trying next ones.
parent 6a9fa629
No related branches found
No related tags found
No related merge requests found
2.8.0.beta9: 851f6cebe3fdd48019660b236a447abb6ddf9c89
2.8.0.beta8: 8002759dacc3c71ecf06fd33f112c84b14b6a59a
2.8.0.beta5: c08ae1e0d301a5f0d264930fa068cdbeb5735ecd
2.7.8: c08ae1e0d301a5f0d264930fa068cdbeb5735ecd
......@@ -204,7 +204,7 @@ class SamlAuthenticator < ::Auth::OAuth2Authenticator
user_params = {
primary_email: UserEmail.new(email: try_email, primary: true),
name: try_name || User.suggest_name(try_username || try_email),
username: UserNameSuggester.suggest(try_username || try_name || try_email || uid),
username: UserNameSuggester.suggest(try_username, try_name, try_email, uid),
active: true
}
......
......@@ -172,6 +172,27 @@ describe SamlAuthenticator do
expect(result.user.id).to eq(Oauth2UserInfo.find_by(uid: @uid, provider: @authenticator.name).user_id)
end
it 'ignores invalid input when automatically creating new account' do
SiteSetting.saml_auto_create_account = true
SiteSetting.unicode_usernames = false
nickname = "άκυρος"
name = "άκυρος"
email = "johndoe@example.com"
hash = OmniAuth::AuthHash.new(
uid: @uid,
info: {
name: name,
nickname: nickname,
email: email
}
)
result = @authenticator.after_authenticate(hash)
expect(result.user.username).to eq("johndoe")
end
describe "username" do
let(:name) { "John Doe" }
let(:email) { "johndoe@example.com" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment