FIX: Hide user's bio if profile is restricted

The bio was sometimes visible in the meta tags even though it it should
not have been.
This commit is contained in:
Bianca Nenciu 2022-01-04 21:34:17 +02:00 committed by Alan Guo Xiang Tan
parent 8d61b2c67d
commit 5e2e178fcf
2 changed files with 11 additions and 1 deletions

View File

@ -101,7 +101,7 @@ module UserGuardian
end
def restrict_user_fields?(user)
user.trust_level == TrustLevel[0] && anonymous?
(user.trust_level == TrustLevel[0] && anonymous?) || !can_see_profile?(user)
end
def can_see_staff_info?(user)

View File

@ -3674,6 +3674,16 @@ describe UsersController do
expect(response.body).to include(user1.username)
end
it "should not be able to view a private user profile" do
user1.user_profile.update!(bio_raw: "Hello world!")
user1.user_option.update!(hide_profile_and_presence: true)
get "/u/#{user1.username}"
expect(response.status).to eq(200)
expect(response.body).not_to include("Hello world!")
end
describe 'when username contains a period' do
before_all do
user1.update!(username: 'test.test')