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
a612bd07
Commit
a612bd07
authored
Jan 31, 2019
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify user requirements for API slugs
parent
33200ed6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
4 deletions
+5
-4
lib/api/api.rb
lib/api/api.rb
+1
-0
lib/api/projects.rb
lib/api/projects.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+3
-3
No files found.
lib/api/api.rb
View file @
a612bd07
...
...
@@ -9,6 +9,7 @@ module API
NO_SLASH_URL_PART_REGEX
=
%r{[^/]+}
NAMESPACE_OR_PROJECT_REQUIREMENTS
=
{
id:
NO_SLASH_URL_PART_REGEX
}.
freeze
COMMIT_ENDPOINT_REQUIREMENTS
=
NAMESPACE_OR_PROJECT_REQUIREMENTS
.
merge
(
sha:
NO_SLASH_URL_PART_REGEX
).
freeze
USER_REQUIREMENTS
=
{
user_id:
NO_SLASH_URL_PART_REGEX
}.
freeze
insert_before
Grape
::
Middleware
::
Error
,
GrapeLogging
::
Middleware
::
RequestLogger
,
...
...
lib/api/projects.rb
View file @
a612bd07
...
...
@@ -128,7 +128,7 @@ module API
end
end
resource
:users
,
requirements:
{
user_id:
API
::
NO_SLASH_URL_PART_REGEX
}
do
resource
:users
,
requirements:
API
::
USER_REQUIREMENTS
do
desc
'Get a user projects'
do
success
Entities
::
BasicProjectDetails
end
...
...
lib/api/users.rb
View file @
a612bd07
...
...
@@ -133,10 +133,10 @@ module API
desc
"Get the status of a user"
params
do
requires
:
id_or_username
,
type:
String
,
desc:
'The ID or username of the user'
requires
:
user_id
,
type:
String
,
desc:
'The ID or username of the user'
end
get
":
id_or_username/status"
,
requirements:
{
id_or_username:
API
::
NO_SLASH_URL_PART_REGEX
}
do
user
=
find_user
(
params
[
:
id_or_username
])
get
":
user_id/status"
,
requirements:
API
::
USER_REQUIREMENTS
do
user
=
find_user
(
params
[
:
user_id
])
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
present
user
.
status
||
{},
with:
Entities
::
UserStatus
...
...
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