Commit 21db5f40 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'xanf-blocked-profile-page' into 'master'

Resolve "Profile page remains active after user has been blocked"

See merge request gitlab-org/gitlab!21706
parents 246802f7 2247089a
...@@ -10,6 +10,9 @@ class UserPolicy < BasePolicy ...@@ -10,6 +10,9 @@ class UserPolicy < BasePolicy
desc "The profile is private" desc "The profile is private"
condition(:private_profile, scope: :subject, score: 0) { @subject.private_profile? } condition(:private_profile, scope: :subject, score: 0) { @subject.private_profile? }
desc "The user is blocked"
condition(:blocked_user, scope: :subject, score: 0) { @subject.blocked? }
rule { ~restricted_public_level }.enable :read_user rule { ~restricted_public_level }.enable :read_user
rule { ~anonymous }.enable :read_user rule { ~anonymous }.enable :read_user
...@@ -20,5 +23,5 @@ class UserPolicy < BasePolicy ...@@ -20,5 +23,5 @@ class UserPolicy < BasePolicy
end end
rule { default }.enable :read_user_profile rule { default }.enable :read_user_profile
rule { private_profile & ~(user_is_self | admin) }.prevent :read_user_profile rule { (private_profile | blocked_user) & ~(user_is_self | admin) }.prevent :read_user_profile
end end
%p
%span.middle-dot-divider
@#{@user.username}
- if can?(current_user, :read_user_profile, @user)
%span.middle-dot-divider
= s_('Member since %{date}') % { date: @user.created_at.to_date.to_s(:long) }
- @hide_top_links = true - @hide_top_links = true
- @hide_breadcrumbs = true - @hide_breadcrumbs = true
- @no_container = true - @no_container = true
- page_title @user.name - page_title @user.blocked? ? s_('UserProfile|Blocked user') : @user.name
- page_description @user.bio - page_description @user.bio
- header_title @user.name, user_path(@user) - header_title @user.name, user_path(@user)
...@@ -36,50 +36,48 @@ ...@@ -36,50 +36,48 @@
= link_to avatar_icon_for_user(@user, 400), target: '_blank', rel: 'noopener noreferrer' do = link_to avatar_icon_for_user(@user, 400), target: '_blank', rel: 'noopener noreferrer' do
= image_tag avatar_icon_for_user(@user, 90), class: "avatar s90", alt: '' = image_tag avatar_icon_for_user(@user, 90), class: "avatar s90", alt: ''
.user-info - if @user.blocked?
.cover-title .user-info
= @user.name .cover-title
= s_('UserProfile|Blocked user')
- if @user.status = render "users/profile_basic_info"
.cover-status - else
= emoji_icon(@user.status.emoji) .user-info
= markdown_field(@user.status, :message) .cover-title
= @user.name
.cover-desc.member-date.cgray
%p - if @user.status
%span.middle-dot-divider .cover-status
@#{@user.username} = emoji_icon(@user.status.emoji)
- if can?(current_user, :read_user_profile, @user) = markdown_field(@user.status, :message)
%span.middle-dot-divider = render "users/profile_basic_info"
= s_('Member since %{date}') % { date: @user.created_at.to_date.to_s(:long) } .cover-desc.cgray
- unless @user.public_email.blank?
.cover-desc.cgray .profile-link-holder.middle-dot-divider
- unless @user.public_email.blank? = link_to @user.public_email, "mailto:#{@user.public_email}", class: 'text-link'
.profile-link-holder.middle-dot-divider - unless @user.skype.blank?
= link_to @user.public_email, "mailto:#{@user.public_email}", class: 'text-link' .profile-link-holder.middle-dot-divider
- unless @user.skype.blank? = link_to "skype:#{@user.skype}", title: "Skype" do
.profile-link-holder.middle-dot-divider = icon('skype')
= link_to "skype:#{@user.skype}", title: "Skype" do - unless @user.linkedin.blank?
= icon('skype') .profile-link-holder.middle-dot-divider
- unless @user.linkedin.blank? = link_to linkedin_url(@user), title: "LinkedIn", target: '_blank', rel: 'noopener noreferrer nofollow' do
.profile-link-holder.middle-dot-divider = icon('linkedin-square')
= link_to linkedin_url(@user), title: "LinkedIn", target: '_blank', rel: 'noopener noreferrer nofollow' do - unless @user.twitter.blank?
= icon('linkedin-square') .profile-link-holder.middle-dot-divider
- unless @user.twitter.blank? = link_to twitter_url(@user), title: "Twitter", target: '_blank', rel: 'noopener noreferrer nofollow' do
.profile-link-holder.middle-dot-divider = icon('twitter-square')
= link_to twitter_url(@user), title: "Twitter", target: '_blank', rel: 'noopener noreferrer nofollow' do - unless @user.website_url.blank?
= icon('twitter-square') .profile-link-holder.middle-dot-divider
- unless @user.website_url.blank? = link_to @user.short_website_url, @user.full_website_url, class: 'text-link', target: '_blank', rel: 'me noopener noreferrer nofollow'
.profile-link-holder.middle-dot-divider - unless @user.location.blank?
= link_to @user.short_website_url, @user.full_website_url, class: 'text-link', target: '_blank', rel: 'me noopener noreferrer nofollow' .profile-link-holder.middle-dot-divider
- unless @user.location.blank? = sprite_icon('location', size: 16, css_class: 'vertical-align-sub')
.profile-link-holder.middle-dot-divider = @user.location
= sprite_icon('location', size: 16, css_class: 'vertical-align-sub') - unless @user.organization.blank?
= @user.location .profile-link-holder.middle-dot-divider
- unless @user.organization.blank? = sprite_icon('work', size: 16, css_class: 'vertical-align-sub')
.profile-link-holder.middle-dot-divider = @user.organization
= sprite_icon('work', size: 16, css_class: 'vertical-align-sub')
= @user.organization
- if @user.bio.present? - if @user.bio.present?
.cover-desc.cgray .cover-desc.cgray
...@@ -165,4 +163,8 @@ ...@@ -165,4 +163,8 @@
.col-12.text-center .col-12.text-center
.text-content .text-content
%h4 %h4
= s_('UserProfile|This user has a private profile') - if @user.blocked?
= s_('UserProfile|This user is blocked')
- else
= s_('UserProfile|This user has a private profile')
---
title: Hide profile information when user is blocked
merge_request: 21706
author:
type: added
...@@ -19625,6 +19625,9 @@ msgstr "" ...@@ -19625,6 +19625,9 @@ msgstr ""
msgid "UserProfile|Already reported for abuse" msgid "UserProfile|Already reported for abuse"
msgstr "" msgstr ""
msgid "UserProfile|Blocked user"
msgstr ""
msgid "UserProfile|Contributed projects" msgid "UserProfile|Contributed projects"
msgstr "" msgstr ""
...@@ -19685,6 +19688,9 @@ msgstr "" ...@@ -19685,6 +19688,9 @@ msgstr ""
msgid "UserProfile|This user hasn't starred any projects" msgid "UserProfile|This user hasn't starred any projects"
msgstr "" msgstr ""
msgid "UserProfile|This user is blocked"
msgstr ""
msgid "UserProfile|View all" msgid "UserProfile|View all"
msgstr "" msgstr ""
......
...@@ -59,6 +59,42 @@ describe 'User page' do ...@@ -59,6 +59,42 @@ describe 'User page' do
end end
end end
context 'with blocked profile' do
let(:user) { create(:user, state: :blocked) }
it 'shows no tab' do
visit(user_path(user))
expect(page).to have_css("div.profile-header")
expect(page).not_to have_css("ul.nav-links")
end
it 'shows blocked message' do
visit(user_path(user))
expect(page).to have_content("This user is blocked")
end
it 'shows user name as blocked' do
visit(user_path(user))
expect(page).to have_css(".cover-title", text: 'Blocked user')
end
it 'shows no additional fields' do
visit(user_path(user))
expect(page).not_to have_css(".profile-user-bio")
expect(page).not_to have_css(".profile-link-holder")
end
it 'shows username' do
visit(user_path(user))
expect(page).to have_content("@#{user.username}")
end
end
it 'shows the status if there was one' do it 'shows the status if there was one' do
create(:user_status, user: user, message: "Working hard!") create(:user_status, user: user, message: "Working hard!")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment