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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
f21b15d5
Commit
f21b15d5
authored
Feb 04, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit projects to user available projects if user is not an admin
parent
b58744cd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
lib/api/entities.rb
lib/api/entities.rb
+7
-1
lib/api/runners.rb
lib/api/runners.rb
+5
-1
No files found.
lib/api/entities.rb
View file @
f21b15d5
...
...
@@ -388,7 +388,13 @@ module API
expose
:version
,
:revision
,
:platform
,
:architecture
expose
:contacted_at
,
as: :last_contact
expose
:token
,
if:
lambda
{
|
runner
,
options
|
options
[
:user_is_admin
]
||
!
runner
.
is_shared?
}
expose
:projects
,
with:
Entities
::
RunnerProjectDetails
expose
:projects
,
with:
Entities
::
RunnerProjectDetails
do
|
runner
,
options
|
if
options
[
:user_is_admin
]
runner
.
projects
else
runner
.
projects
.
where
(
id:
options
[
:available_projects_ids
])
end
end
end
class
Build
<
Grape
::
Entity
...
...
lib/api/runners.rb
View file @
f21b15d5
...
...
@@ -33,7 +33,11 @@ module API
runner
=
get_runner
(
params
[
:id
])
authenticate_show_runner!
(
runner
)
present
runner
,
with:
Entities
::
RunnerDetails
,
user_is_admin:
current_user
.
is_admin?
available_projects_ids
=
runner
.
projects
.
select
{
|
p
|
can?
(
current_user
,
:read_project
,
p
)
}
.
map
(
&
:id
)
unless
current_user
.
is_admin?
present
runner
,
with:
Entities
::
RunnerDetails
,
user_is_admin:
current_user
.
is_admin?
,
available_projects_ids:
available_projects_ids
end
# Update runner's details
...
...
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