DEV: simplify username suggester (#14531)

This PR doesn't change any behavior, but just removes code that wasn't in use. This is a pretty dangerous place to change, since it gets called during user's registration. At the same time the refactoring is very straightforward, it's clear that this code wasn't doing any work (it still needs to be double-checked during review though). Also, the test coverage of UserNameSuggester is good.
This commit is contained in:
Andrei Prigorshnev
2021-10-27 14:41:24 +04:00
committed by GitHub
parent 69f0f48dc0
commit 19d95c64af
5 changed files with 52 additions and 62 deletions

View File

@ -323,8 +323,8 @@ class DiscourseSingleSignOn < SingleSignOn
if SiteSetting.auth_overrides_username? && username.present?
if user.username.downcase == username.downcase
user.username = username # there may be a change of case
elsif user.username != username
user.username = UserNameSuggester.suggest(username || name || email, user.username)
elsif user.username != UserNameSuggester.fix_username(username)
user.username = UserNameSuggester.suggest(username)
end
end