anonymous shadow users are approved on creation if must_approve_users is enabled (#5569)
This commit is contained in:
parent
e924de71e7
commit
1c27d93dcf
|
@ -13,6 +13,7 @@ class AnonymousShadowCreator
|
||||||
return unless user
|
return unless user
|
||||||
return unless SiteSetting.allow_anonymous_posting
|
return unless SiteSetting.allow_anonymous_posting
|
||||||
return if user.trust_level < SiteSetting.anonymous_posting_min_trust_level
|
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
|
if (shadow_id = user.custom_fields["shadow_id"].to_i) > 0
|
||||||
shadow = User.find_by(id: shadow_id)
|
shadow = User.find_by(id: shadow_id)
|
||||||
|
@ -40,6 +41,8 @@ class AnonymousShadowCreator
|
||||||
active: true,
|
active: true,
|
||||||
trust_level: 1,
|
trust_level: 1,
|
||||||
manual_locked_trust_level: 1,
|
manual_locked_trust_level: 1,
|
||||||
|
approved: true,
|
||||||
|
approved_at: 1.day.ago,
|
||||||
created_at: 1.day.ago # bypass new user restrictions
|
created_at: 1.day.ago # bypass new user restrictions
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,11 @@ describe AnonymousShadowCreator do
|
||||||
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
|
expect(AnonymousShadowCreator.get(Fabricate.build(:user, trust_level: 0))).to eq(nil)
|
||||||
end
|
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
|
it "returns a new shadow once time expires" do
|
||||||
SiteSetting.anonymous_account_duration_minutes = 1
|
SiteSetting.anonymous_account_duration_minutes = 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue