mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Check against reserved usernames should be case insensitive.
This commit is contained in:
parent
282a4e1efb
commit
90a0327fd2
2 changed files with 11 additions and 1 deletions
|
@ -147,7 +147,9 @@ 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? && !SiteSetting.reserved_usernames.split("|").include?(username)
|
|
||||||
|
User.where(username_lower: lower).blank? &&
|
||||||
|
!SiteSetting.reserved_usernames.split("|").any? { |reserved| reserved.casecmp(username) == 0 }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.plugin_staff_user_custom_fields
|
def self.plugin_staff_user_custom_fields
|
||||||
|
|
|
@ -433,6 +433,14 @@ describe User do
|
||||||
it 'returns false when a username is taken' do
|
it 'returns false when a username is taken' do
|
||||||
expect(User.username_available?(Fabricate(:user).username)).to eq(false)
|
expect(User.username_available?(Fabricate(:user).username)).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns false when a username is reserved' do
|
||||||
|
SiteSetting.reserved_usernames = 'test|donkey'
|
||||||
|
|
||||||
|
expect(User.username_available?('donkey')).to eq(false)
|
||||||
|
expect(User.username_available?('DonKey')).to eq(false)
|
||||||
|
expect(User.username_available?('test')).to eq(false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'email_validator' do
|
describe 'email_validator' do
|
||||||
|
|
Loading…
Reference in a new issue