mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Merge pull request #3463 from techAPJ/patch-2
FIX: match subdomain with email domain blacklist
This commit is contained in:
commit
bb29bff5d8
2 changed files with 6 additions and 1 deletions
|
@ -17,7 +17,7 @@ class EmailValidator < ActiveModel::EachValidator
|
|||
|
||||
def email_in_restriction_setting?(setting, value)
|
||||
domains = setting.gsub('.', '\.')
|
||||
regexp = Regexp.new("@(#{domains})", true)
|
||||
regexp = Regexp.new("@(.+\.)?(#{domains})", true)
|
||||
value =~ regexp
|
||||
end
|
||||
|
||||
|
|
|
@ -440,6 +440,11 @@ describe User do
|
|||
expect(Fabricate.build(:user, email: 'notgood@TRASHMAIL.NET')).not_to be_valid
|
||||
end
|
||||
|
||||
it 'should reject emails based on the email_domains_blacklist site setting matching subdomain' do
|
||||
SiteSetting.stubs(:email_domains_blacklist).returns('domain.com')
|
||||
expect(Fabricate.build(:user, email: 'notgood@sub.domain.com')).not_to be_valid
|
||||
end
|
||||
|
||||
it 'blacklist should not reject developer emails' do
|
||||
Rails.configuration.stubs(:developer_emails).returns('developer@discourse.org')
|
||||
SiteSetting.stubs(:email_domains_blacklist).returns('discourse.org')
|
||||
|
|
Loading…
Reference in a new issue