mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08: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
|
end
|
||||||
|
|
||||||
def email_validator
|
def email_validator
|
||||||
if (setting = SiteSetting.email_domains_blacklist).present?
|
if new_record? and (setting = SiteSetting.email_domains_blacklist).present?
|
||||||
domains = setting.gsub('.', '\.')
|
domains = setting.gsub('.', '\.')
|
||||||
regexp = Regexp.new("@(#{domains})", true)
|
regexp = Regexp.new("@(#{domains})", true)
|
||||||
if self.email =~ regexp
|
if self.email =~ regexp
|
||||||
|
|
|
@ -478,6 +478,12 @@ describe User do
|
||||||
SiteSetting.stubs(:email_domains_blacklist).returns('trashmail.net')
|
SiteSetting.stubs(:email_domains_blacklist).returns('trashmail.net')
|
||||||
Fabricate.build(:user, email: 'good@trashmailinet.com').should be_valid
|
Fabricate.build(:user, email: 'good@trashmailinet.com').should be_valid
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'passwords' do
|
describe 'passwords' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue