anonymous shadow users are approved on creation if must_approve_users is enabled (#5569)

This commit is contained in:
Maja Komel 2018-02-13 07:58:38 +01:00 committed by Sam
parent e924de71e7
commit 1c27d93dcf
2 changed files with 8 additions and 0 deletions

View File

@ -13,6 +13,7 @@ class AnonymousShadowCreator
return unless user
return unless SiteSetting.allow_anonymous_posting
return if user.trust_level < SiteSetting.anonymous_posting_min_trust_level
return if SiteSetting.must_approve_users? && !user.approved?
if (shadow_id = user.custom_fields["shadow_id"].to_i) > 0
shadow = User.find_by(id: shadow_id)
@ -40,6 +41,8 @@ class AnonymousShadowCreator
active: true,
trust_level: 1,
manual_locked_trust_level: 1,
approved: true,
approved_at: 1.day.ago,
created_at: 1.day.ago # bypass new user restrictions
)

View File

@ -16,6 +16,11 @@ describe AnonymousShadowCreator do
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
end
it "returns no shadow if must_approve_users is true and user is not approved" do
SiteSetting.must_approve_users = true
expect(AnonymousShadowCreator.get(Fabricate.build(:user, approved: false))).to eq(nil)
end
it "returns a new shadow once time expires" do
SiteSetting.anonymous_account_duration_minutes = 1