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
Show 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
desc
"The profile is private"
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
{
~
anonymous
}.
enable
:read_user
...
...
@@ -20,5 +23,5 @@ class UserPolicy < BasePolicy
end
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
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_breadcrumbs
=
true
-
@no_container
=
true
-
page_title
@user
.
name
-
page_title
@user
.
blocked?
?
s_
(
'UserProfile|Blocked user'
)
:
@user
.
name
-
page_description
@user
.
bio
-
header_title
@user
.
name
,
user_path
(
@user
)
...
...
@@ -36,6 +36,12 @@
=
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:
''
-
if
@user
.
blocked?
.user-info
.cover-title
=
s_
(
'UserProfile|Blocked user'
)
=
render
"users/profile_basic_info"
-
else
.user-info
.cover-title
=
@user
.
name
...
...
@@ -44,15 +50,7 @@
.cover-status
=
emoji_icon
(
@user
.
status
.
emoji
)
=
markdown_field
(
@user
.
status
,
:message
)
.cover-desc.member-date.cgray
%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
)
}
=
render
"users/profile_basic_info"
.cover-desc.cgray
-
unless
@user
.
public_email
.
blank?
.profile-link-holder.middle-dot-divider
...
...
@@ -165,4 +163,8 @@
.col-12.text-center
.text-content
%h4
-
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 ""
msgid "UserProfile|Already reported for abuse"
msgstr ""
msgid "UserProfile|Blocked user"
msgstr ""
msgid "UserProfile|Contributed projects"
msgstr ""
...
...
@@ -19661,6 +19664,9 @@ msgstr ""
msgid "UserProfile|This user hasn't starred any projects"
msgstr ""
msgid "UserProfile|This user is blocked"
msgstr ""
msgid "UserProfile|View all"
msgstr ""
...
...
spec/features/users/show_spec.rb
View file @
2247089a
...
...
@@ -59,6 +59,42 @@ describe 'User page' do
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
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