mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:40:53 -06:00
FIX: Allow half-merged user to be accessed in admin UI (#22105)
This commit is contained in:
parent
a674c6c4c2
commit
3fe06bba9d
@ -74,7 +74,7 @@ module UserGuardian
|
||||
end
|
||||
|
||||
def can_anonymize_user?(user)
|
||||
is_staff? && !user.nil? && !user.staff? && !user.email.ends_with?(UserAnonymizer::EMAIL_SUFFIX)
|
||||
is_staff? && !user.nil? && !user.staff? && !user.email&.ends_with?(UserAnonymizer::EMAIL_SUFFIX)
|
||||
end
|
||||
|
||||
def can_merge_user?(user)
|
||||
|
@ -2777,10 +2777,16 @@ RSpec.describe Guardian do
|
||||
expect(Guardian.new(user).can_anonymize_user?(user)).to be_falsey
|
||||
end
|
||||
|
||||
it "it false for an anonymized user" do
|
||||
it "is false for an anonymized user" do
|
||||
expect(Guardian.new(user).can_anonymize_user?(anonymous_user)).to be_falsey
|
||||
end
|
||||
|
||||
it "is true for a user with no email" do
|
||||
bad_state_user = Fabricate.build(:user, email: nil)
|
||||
bad_state_user.skip_email_validation = true
|
||||
expect(Guardian.new(moderator).can_anonymize_user?(bad_state_user)).to eq(true)
|
||||
end
|
||||
|
||||
it "is true for admin anonymizing a regular user" do
|
||||
expect(Guardian.new(admin).can_anonymize_user?(user)).to eq(true)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user