Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2247089a
Commit
2247089a
authored
Dec 13, 2019
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide profile information when user is blocked
When user is blocked all information is hidden, except: - username
parent
26ccbc3e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
47 deletions
+105
-47
app/policies/user_policy.rb
app/policies/user_policy.rb
+4
-1
app/views/users/_profile_basic_info.html.haml
app/views/users/_profile_basic_info.html.haml
+6
-0
app/views/users/show.html.haml
app/views/users/show.html.haml
+48
-46
changelogs/unreleased/xanf-blocked-profile-page.yml
changelogs/unreleased/xanf-blocked-profile-page.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/features/users/show_spec.rb
spec/features/users/show_spec.rb
+36
-0
No files found.
app/policies/user_policy.rb
View file @
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
app/views/users/_profile_basic_info.html.haml
0 → 100644
View file @
2247089a
%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
)
}
app/views/users/show.html.haml
View file @
2247089a
-
@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'
)
changelogs/unreleased/xanf-blocked-profile-page.yml
0 → 100644
View file @
2247089a
---
title
:
Hide profile information when user is blocked
merge_request
:
21706
author
:
type
:
added
locale/gitlab.pot
View file @
2247089a
...
@@ -19601,6 +19601,9 @@ msgstr ""
...
@@ -19601,6 +19601,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 ""
...
@@ -19661,6 +19664,9 @@ msgstr ""
...
@@ -19661,6 +19664,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 ""
...
...
spec/features/users/show_spec.rb
View file @
2247089a
...
@@ -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!"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment