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
da67dca1
Commit
da67dca1
authored
Feb 23, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use grape to validate parameters in the members API
parent
a77b40d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
lib/api/members.rb
lib/api/members.rb
+3
-4
lib/api/v3/members.rb
lib/api/v3/members.rb
+3
-4
No files found.
lib/api/members.rb
View file @
da67dca1
...
...
@@ -79,13 +79,12 @@ module API
optional
:expires_at
,
type:
DateTime
,
desc:
'Date string in the format YEAR-MONTH-DAY'
end
put
":id/members/:user_id"
do
source
=
find_source
(
source_type
,
params
[
:id
]
)
source
=
find_source
(
source_type
,
params
.
delete
(
:id
)
)
authorize_admin_source!
(
source_type
,
source
)
member
=
source
.
members
.
find_by!
(
user_id:
params
[
:user_id
])
attrs
=
attributes_for_keys
[
:access_level
,
:expires_at
]
member
=
source
.
members
.
find_by!
(
user_id:
params
.
delete
(
:user_id
))
if
member
.
update_attributes
(
attrs
)
if
member
.
update_attributes
(
declared_params
(
include_missing:
false
)
)
present
member
.
user
,
with:
Entities
::
Member
,
member:
member
else
# This is to ensure back-compatibility but 400 behavior should be used
...
...
lib/api/v3/members.rb
View file @
da67dca1
...
...
@@ -86,13 +86,12 @@ module API
optional
:expires_at
,
type:
DateTime
,
desc:
'Date string in the format YEAR-MONTH-DAY'
end
put
":id/members/:user_id"
do
source
=
find_source
(
source_type
,
params
[
:id
]
)
source
=
find_source
(
source_type
,
params
.
delete
(
:id
)
)
authorize_admin_source!
(
source_type
,
source
)
member
=
source
.
members
.
find_by!
(
user_id:
params
[
:user_id
])
attrs
=
attributes_for_keys
[
:access_level
,
:expires_at
]
member
=
source
.
members
.
find_by!
(
user_id:
params
.
delete
(
:user_id
))
if
member
.
update_attributes
(
attrs
)
if
member
.
update_attributes
(
declared_params
(
include_missing:
false
)
)
present
member
.
user
,
with:
::
API
::
Entities
::
Member
,
member:
member
else
# This is to ensure back-compatibility but 400 behavior should be used
...
...
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