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
91f63820
Unverified
Commit
91f63820
authored
Jul 12, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return `is_admin` attribute in the GET /user endpoint for admins
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
dc05bcd8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
6 deletions
+53
-6
34325-reinstate-is_admin-for-user-api.yml
...logs/unreleased/34325-reinstate-is_admin-for-user-api.yml
+4
-0
users.md
doc/api/users.md
+1
-1
users.rb
lib/api/users.rb
+10
-1
admin.json
spec/fixtures/api/schemas/public_api/v4/user/admin.json
+34
-0
users_spec.rb
spec/requests/api/users_spec.rb
+4
-4
No files found.
changelogs/unreleased/34325-reinstate-is_admin-for-user-api.yml
0 → 100644
View file @
91f63820
---
title
:
Return `is_admin` attribute in the GET /user endpoint for admins
merge_request
:
12811
author
:
doc/api/users.md
View file @
91f63820
...
@@ -364,7 +364,7 @@ GET /user
...
@@ -364,7 +364,7 @@ GET /user
Parameters:
Parameters:
-
`sudo`
(
required) - the ID of a user
-
`sudo`
(
optional) - the ID of a user to make the call in their place
```
```
GET /user
GET /user
...
...
lib/api/users.rb
View file @
91f63820
...
@@ -421,7 +421,16 @@ module API
...
@@ -421,7 +421,16 @@ module API
success
Entities
::
UserPublic
success
Entities
::
UserPublic
end
end
get
do
get
do
present
current_user
,
with:
sudo?
?
Entities
::
UserWithPrivateDetails
:
Entities
::
UserPublic
entity
=
if
sudo?
Entities
::
UserWithPrivateDetails
elsif
current_user
.
admin?
Entities
::
UserWithAdmin
else
Entities
::
UserPublic
end
present
current_user
,
with:
entity
end
end
desc
"Get the currently authenticated user's SSH keys"
do
desc
"Get the currently authenticated user's SSH keys"
do
...
...
spec/fixtures/api/schemas/public_api/v4/user/admin.json
0 → 100644
View file @
91f63820
{
"type"
:
"object"
,
"required"
:
[
"id"
,
"username"
,
"email"
,
"name"
,
"state"
,
"avatar_url"
,
"web_url"
,
"created_at"
,
"is_admin"
,
"bio"
,
"location"
,
"skype"
,
"linkedin"
,
"twitter"
,
"website_url"
,
"organization"
,
"last_sign_in_at"
,
"confirmed_at"
,
"color_scheme_id"
,
"projects_limit"
,
"current_sign_in_at"
,
"identities"
,
"can_create_group"
,
"can_create_project"
,
"two_factor_enabled"
,
"external"
],
"properties"
:
{
"$ref"
:
"full.json"
}
}
spec/requests/api/users_spec.rb
View file @
91f63820
...
@@ -943,11 +943,11 @@ describe API::Users do
...
@@ -943,11 +943,11 @@ describe API::Users do
expect
(
response
).
to
have_http_status
(
403
)
expect
(
response
).
to
have_http_status
(
403
)
end
end
it
'returns initial current user without private token when sudo not defined'
do
it
'returns initial current user without private token
but with is_admin
when sudo not defined'
do
get
api
(
"/user?private_token=
#{
admin_personal_access_token
}
"
)
get
api
(
"/user?private_token=
#{
admin_personal_access_token
}
"
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/user/
public
'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/user/
admin
'
)
expect
(
json_response
[
'id'
]).
to
eq
(
admin
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
admin
.
id
)
end
end
end
end
...
@@ -961,11 +961,11 @@ describe API::Users do
...
@@ -961,11 +961,11 @@ describe API::Users do
expect
(
json_response
[
'id'
]).
to
eq
(
user
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
user
.
id
)
end
end
it
'returns initial current user without private token when sudo not defined'
do
it
'returns initial current user without private token
but with is_admin
when sudo not defined'
do
get
api
(
"/user?private_token=
#{
admin
.
private_token
}
"
)
get
api
(
"/user?private_token=
#{
admin
.
private_token
}
"
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/user/
public
'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/user/
admin
'
)
expect
(
json_response
[
'id'
]).
to
eq
(
admin
.
id
)
expect
(
json_response
[
'id'
]).
to
eq
(
admin
.
id
)
end
end
end
end
...
...
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