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
1edd7c71
Commit
1edd7c71
authored
Mar 03, 2022
by
Serena Fang
Committed by
Douglas Barbosa Alexandre
Mar 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move secure name method to HasUserType
Move from UsersHelper to HasUserType
parent
79611ed1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
18 deletions
+15
-18
app/graphql/types/user_interface.rb
app/graphql/types/user_interface.rb
+1
-2
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+0
-13
app/models/concerns/has_user_type.rb
app/models/concerns/has_user_type.rb
+13
-0
lib/api/entities/user_safe.rb
lib/api/entities/user_safe.rb
+1
-3
No files found.
app/graphql/types/user_interface.rb
View file @
1edd7c71
...
...
@@ -3,7 +3,6 @@
module
Types
module
UserInterface
include
Types
::
BaseInterface
include
UsersHelper
graphql_name
'User'
description
'Representation of a GitLab user.'
...
...
@@ -137,7 +136,7 @@ module Types
def
redacted_name
return
object
.
name
unless
object
.
project_bot?
secure_project_bot_name
(
context
[
:current_user
],
object
)
object
.
secure_name
(
context
[
:current_user
]
)
end
end
end
app/helpers/users_helper.rb
View file @
1edd7c71
...
...
@@ -176,19 +176,6 @@ module UsersHelper
user
.
public_email
.
present?
end
def
secure_project_bot_name
(
current_user
,
user
)
if
user
.
groups
.
any?
return
user
.
name
if
current_user
&
.
can?
(
:read_group
,
user
.
groups
.
first
)
end
return
user
.
name
if
current_user
&
.
can?
(
:read_project
,
user
.
projects
.
first
)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
private
def
admin_users_paths
...
...
app/models/concerns/has_user_type.rb
View file @
1edd7c71
...
...
@@ -46,4 +46,17 @@ module HasUserType
def
internal?
ghost?
||
(
bot?
&&
!
project_bot?
)
end
def
secure_name
(
viewing_user
)
if
self
.
groups
.
any?
return
self
.
name
if
viewing_user
&
.
can?
(
:read_group
,
self
.
groups
.
first
)
end
return
self
.
name
if
viewing_user
&
.
can?
(
:read_project
,
self
.
projects
.
first
)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/346058
'****'
end
end
lib/api/entities/user_safe.rb
View file @
1edd7c71
...
...
@@ -3,13 +3,11 @@
module
API
module
Entities
class
UserSafe
<
Grape
::
Entity
include
UsersHelper
expose
:id
,
:username
expose
:name
do
|
user
|
next
user
.
name
unless
user
.
project_bot?
secure_project_bot_name
(
options
[
:current_user
],
user
)
user
.
secure_name
(
options
[
:current_user
]
)
end
end
end
...
...
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