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
81ba3f91
Commit
81ba3f91
authored
Nov 24, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Introduce `#find_group!` which also check access permission
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
4f5ed812
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
7 deletions
+15
-7
lib/api/groups.rb
lib/api/groups.rb
+4
-4
lib/api/helpers.rb
lib/api/helpers.rb
+9
-1
lib/api/helpers/members_helpers.rb
lib/api/helpers/members_helpers.rb
+1
-1
lib/api/issues.rb
lib/api/issues.rb
+1
-1
No files found.
lib/api/groups.rb
View file @
81ba3f91
...
@@ -82,7 +82,7 @@ module API
...
@@ -82,7 +82,7 @@ module API
:lfs_enabled
,
:request_access_enabled
:lfs_enabled
,
:request_access_enabled
end
end
put
':id'
do
put
':id'
do
group
=
find_group
(
params
[
:id
])
group
=
find_group
!
(
params
[
:id
])
authorize!
:admin_group
,
group
authorize!
:admin_group
,
group
if
::
Groups
::
UpdateService
.
new
(
group
,
current_user
,
declared_params
(
include_missing:
false
)).
execute
if
::
Groups
::
UpdateService
.
new
(
group
,
current_user
,
declared_params
(
include_missing:
false
)).
execute
...
@@ -96,13 +96,13 @@ module API
...
@@ -96,13 +96,13 @@ module API
success
Entities
::
GroupDetail
success
Entities
::
GroupDetail
end
end
get
":id"
do
get
":id"
do
group
=
find_group
(
params
[
:id
])
group
=
find_group
!
(
params
[
:id
])
present
group
,
with:
Entities
::
GroupDetail
present
group
,
with:
Entities
::
GroupDetail
end
end
desc
'Remove a group.'
desc
'Remove a group.'
delete
":id"
do
delete
":id"
do
group
=
find_group
(
params
[
:id
])
group
=
find_group
!
(
params
[
:id
])
authorize!
:admin_group
,
group
authorize!
:admin_group
,
group
DestroyGroupService
.
new
(
group
,
current_user
).
execute
DestroyGroupService
.
new
(
group
,
current_user
).
execute
end
end
...
@@ -111,7 +111,7 @@ module API
...
@@ -111,7 +111,7 @@ module API
success
Entities
::
Project
success
Entities
::
Project
end
end
get
":id/projects"
do
get
":id/projects"
do
group
=
find_group
(
params
[
:id
])
group
=
find_group
!
(
params
[
:id
])
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
GroupProjectsFinder
.
new
(
group
).
execute
(
current_user
)
projects
=
paginate
projects
projects
=
paginate
projects
present
projects
,
with:
Entities
::
Project
,
user:
current_user
present
projects
,
with:
Entities
::
Project
,
user:
current_user
...
...
lib/api/helpers.rb
View file @
81ba3f91
...
@@ -105,7 +105,15 @@ module API
...
@@ -105,7 +105,15 @@ module API
end
end
def
find_group
(
id
)
def
find_group
(
id
)
group
=
Group
.
find_by
(
path:
id
)
||
Group
.
find_by
(
id:
id
)
if
id
=~
/^\d+$/
Group
.
find_by
(
id:
id
)
else
Group
.
find_by
(
path:
id
)
end
end
def
find_group!
(
id
)
group
=
find_group
(
id
)
if
can?
(
current_user
,
:read_group
,
group
)
if
can?
(
current_user
,
:read_group
,
group
)
group
group
...
...
lib/api/helpers/members_helpers.rb
View file @
81ba3f91
...
@@ -2,7 +2,7 @@ module API
...
@@ -2,7 +2,7 @@ module API
module
Helpers
module
Helpers
module
MembersHelpers
module
MembersHelpers
def
find_source
(
source_type
,
id
)
def
find_source
(
source_type
,
id
)
public_send
(
"find_
#{
source_type
}
"
,
id
)
public_send
(
"find_
#{
source_type
}
!
"
,
id
)
end
end
def
authorize_admin_source!
(
source_type
,
source
)
def
authorize_admin_source!
(
source_type
,
source
)
...
...
lib/api/issues.rb
View file @
81ba3f91
...
@@ -68,7 +68,7 @@ module API
...
@@ -68,7 +68,7 @@ module API
# GET /groups/:id/issues?milestone=1.0.0
# GET /groups/:id/issues?milestone=1.0.0
# GET /groups/:id/issues?milestone=1.0.0&state=closed
# GET /groups/:id/issues?milestone=1.0.0&state=closed
get
":id/issues"
do
get
":id/issues"
do
group
=
find_group
(
params
[
:id
])
group
=
find_group
!
(
params
[
:id
])
params
[
:state
]
||=
'opened'
params
[
:state
]
||=
'opened'
params
[
:group_id
]
=
group
.
id
params
[
:group_id
]
=
group
.
id
...
...
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