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
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
Show 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
...
@@ -9,6 +9,7 @@ module API
NO_SLASH_URL_PART_REGEX
=
%r{[^/]+}
NO_SLASH_URL_PART_REGEX
=
%r{[^/]+}
NAMESPACE_OR_PROJECT_REQUIREMENTS
=
{
id:
NO_SLASH_URL_PART_REGEX
}.
freeze
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
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
,
insert_before
Grape
::
Middleware
::
Error
,
GrapeLogging
::
Middleware
::
RequestLogger
,
GrapeLogging
::
Middleware
::
RequestLogger
,
...
...
lib/api/projects.rb
View file @
a612bd07
...
@@ -128,7 +128,7 @@ module API
...
@@ -128,7 +128,7 @@ module API
end
end
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
desc
'Get a user projects'
do
success
Entities
::
BasicProjectDetails
success
Entities
::
BasicProjectDetails
end
end
...
...
lib/api/users.rb
View file @
a612bd07
...
@@ -133,10 +133,10 @@ module API
...
@@ -133,10 +133,10 @@ module API
desc
"Get the status of a user"
desc
"Get the status of a user"
params
do
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
end
get
":
id_or_username/status"
,
requirements:
{
id_or_username:
API
::
NO_SLASH_URL_PART_REGEX
}
do
get
":
user_id/status"
,
requirements:
API
::
USER_REQUIREMENTS
do
user
=
find_user
(
params
[
:
id_or_username
])
user
=
find_user
(
params
[
:
user_id
])
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
not_found!
(
'User'
)
unless
user
&&
can?
(
current_user
,
:read_user
,
user
)
present
user
.
status
||
{},
with:
Entities
::
UserStatus
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