FIX: email_domains_whitelist prevented creation of anonymous users

This commit is contained in:
Gerhard Schlager 2018-03-06 18:14:53 +01:00
parent 76e2b6c825
commit 07649cd42d
2 changed files with 7 additions and 1 deletions

View File

@ -36,6 +36,7 @@ class AnonymousShadowCreator
shadow = User.create!(
password: SecureRandom.hex,
email: "#{SecureRandom.hex}@anon.#{Discourse.current_hostname}",
skip_email_validation: true,
name: username, # prevents error when names are required
username: username,
active: true,

View File

@ -10,7 +10,7 @@ describe AnonymousShadowCreator do
before { SiteSetting.allow_anonymous_posting = true }
let(:user) { Fabricate(:user, trust_level: 3) }
let(:user) { Fabricate(:user_single_email, trust_level: 3) }
it "returns no shadow if trust level is not met" do
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
@ -67,6 +67,11 @@ describe AnonymousShadowCreator do
expect { AnonymousShadowCreator.get(user) }.to_not raise_error
end
it "works when there is an email whitelist" do
SiteSetting.email_domains_whitelist = "wayne.com"
expect { AnonymousShadowCreator.get(user) }.to_not raise_error
end
end
end