discourse/plugins/chat/spec/system/user_profile_spec.rb
Osama Sayegh 976aca68f6
FEATURE: Restrict profile visibility of low-trust users (#29981)
We've seen in some communities abuse of user profile where bios and other fields are used in malicious ways, such as malware distribution. A common pattern between all the abuse cases we've seen is that the malicious actors tend to have 0 posts and have a low trust level.

To eliminate this abuse vector, or at least make it much less effective, we're making the following changes to user profiles:

1. Anonymous, TL0 and TL1 users cannot see any user profiles for users with 0 posts except for staff users
2. Anonymous and TL0 users can only see profiles of TL1 users and above

Users can always see their own profile, and they can still hide their profiles via the "Hide my public profile" preference. Staff can always see any user's profile.

Internal topic: t/142853.
2024-12-09 13:07:59 +03:00

55 lines
1.1 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "User profile", type: :system do
fab!(:current_user) { Fabricate(:user) }
fab!(:user)
before do
user.user_stat.update!(post_count: 1)
chat_system_bootstrap
end
shared_examples "not showing chat button" do
it "has no chat button" do
expect(page).to have_no_css(".chat-direct-message-btn")
end
end
shared_examples "showing chat button" do
it "shows the chat button" do
expect(page).to have_css(".chat-direct-message-btn")
end
end
def visit_user_profile
visit("/u/" + user.username + "/summary")
end
context "when user" do
context "with chat disabled" do
before do
SiteSetting.chat_enabled = false
sign_in(current_user)
visit_user_profile
end
include_examples "not showing chat button"
end
context "with chat enabled" do
before do
sign_in(current_user)
visit_user_profile
end
include_examples "showing chat button"
end
end
context "when anonymous" do
before { visit_user_profile }
include_examples "not showing chat button"
end
end