BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
entities.rb
lib/api/entities.rb
+7
-1
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