mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
FIX: Consider reserved usernames as not 'available'
https://meta.discourse.org/t/reserved-usernames-ignored-by-invites/32490
This commit is contained in:
parent
01406c65a6
commit
1586886bf9
2 changed files with 7 additions and 1 deletions
|
@ -149,7 +149,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def self.username_available?(username)
|
def self.username_available?(username)
|
||||||
lower = username.downcase
|
lower = username.downcase
|
||||||
User.where(username_lower: lower).blank?
|
User.where(username_lower: lower).blank? && !SiteSetting.reserved_usernames.split("|").include?(username)
|
||||||
end
|
end
|
||||||
|
|
||||||
def effective_locale
|
def effective_locale
|
||||||
|
|
|
@ -49,6 +49,12 @@ describe UserNameSuggester do
|
||||||
expect(UserNameSuggester.suggest("myreallylongnam")).to eq('myreallylongna1')
|
expect(UserNameSuggester.suggest("myreallylongnam")).to eq('myreallylongna1')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't suggest reserved usernames" do
|
||||||
|
SiteSetting.reserved_usernames = 'admin|steve|steve1'
|
||||||
|
expect(UserNameSuggester.suggest("admin@hissite.com")).to eq('admin1')
|
||||||
|
expect(UserNameSuggester.suggest("steve")).to eq('steve2')
|
||||||
|
end
|
||||||
|
|
||||||
it "removes leading character if it is not alphanumeric" do
|
it "removes leading character if it is not alphanumeric" do
|
||||||
expect(UserNameSuggester.suggest("_myname")).to eq('myname')
|
expect(UserNameSuggester.suggest("_myname")).to eq('myname')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue