mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Changes to email_domains_blacklist shouldn't invalidate existing users
This commit is contained in:
parent
a588f62fc7
commit
046c330858
2 changed files with 7 additions and 1 deletions
|
@ -506,7 +506,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def email_validator
|
||||
if (setting = SiteSetting.email_domains_blacklist).present?
|
||||
if new_record? and (setting = SiteSetting.email_domains_blacklist).present?
|
||||
domains = setting.gsub('.', '\.')
|
||||
regexp = Regexp.new("@(#{domains})", true)
|
||||
if self.email =~ regexp
|
||||
|
|
|
@ -478,6 +478,12 @@ describe User do
|
|||
SiteSetting.stubs(:email_domains_blacklist).returns('trashmail.net')
|
||||
Fabricate.build(:user, email: 'good@trashmailinet.com').should be_valid
|
||||
end
|
||||
|
||||
it 'should not be used to validate existing records' do
|
||||
u = Fabricate(:user, email: 'in_before_blacklisted@fakemail.com')
|
||||
SiteSetting.stubs(:email_domains_blacklist).returns('fakemail.com')
|
||||
u.should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe 'passwords' do
|
||||
|
|
Loading…
Reference in a new issue