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
Boxiang Sun
gitlab-ce
Commits
d0b556eb
Commit
d0b556eb
authored
Sep 26, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add User#organization to users api
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
107866d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
doc/api/users.md
doc/api/users.md
+8
-1
lib/api/entities.rb
lib/api/entities.rb
+1
-1
lib/api/users.rb
lib/api/users.rb
+4
-2
spec/requests/api/users_spec.rb
spec/requests/api/users_spec.rb
+7
-0
No files found.
doc/api/users.md
View file @
d0b556eb
...
@@ -57,6 +57,7 @@ GET /users
...
@@ -57,6 +57,7 @@ GET /users
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"theme_id"
:
1
,
...
@@ -89,6 +90,7 @@ GET /users
...
@@ -89,6 +90,7 @@ GET /users
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
null
,
"last_sign_in_at"
:
null
,
"confirmed_at"
:
"2012-05-30T16:53:06.148Z"
,
"confirmed_at"
:
"2012-05-30T16:53:06.148Z"
,
"theme_id"
:
1
,
"theme_id"
:
1
,
...
@@ -147,7 +149,8 @@ Parameters:
...
@@ -147,7 +149,8 @@ Parameters:
"skype"
:
""
,
"skype"
:
""
,
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
"website_url"
:
""
,
"organization"
:
""
}
}
```
```
...
@@ -178,6 +181,7 @@ Parameters:
...
@@ -178,6 +181,7 @@ Parameters:
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"theme_id"
:
1
,
...
@@ -214,6 +218,7 @@ Parameters:
...
@@ -214,6 +218,7 @@ Parameters:
-
`linkedin`
(optional) - LinkedIn
-
`linkedin`
(optional) - LinkedIn
-
`twitter`
(optional) - Twitter account
-
`twitter`
(optional) - Twitter account
-
`website_url`
(optional) - Website URL
-
`website_url`
(optional) - Website URL
-
`organization`
(optional) - Organization name
-
`projects_limit`
(optional) - Number of projects user can create
-
`projects_limit`
(optional) - Number of projects user can create
-
`extern_uid`
(optional) - External UID
-
`extern_uid`
(optional) - External UID
-
`provider`
(optional) - External provider name
-
`provider`
(optional) - External provider name
...
@@ -242,6 +247,7 @@ Parameters:
...
@@ -242,6 +247,7 @@ Parameters:
-
`linkedin`
- LinkedIn
-
`linkedin`
- LinkedIn
-
`twitter`
- Twitter account
-
`twitter`
- Twitter account
-
`website_url`
- Website URL
-
`website_url`
- Website URL
-
`organization`
- Organization name
-
`projects_limit`
- Limit projects each user can create
-
`projects_limit`
- Limit projects each user can create
-
`extern_uid`
- External UID
-
`extern_uid`
- External UID
-
`provider`
- External provider name
-
`provider`
- External provider name
...
@@ -296,6 +302,7 @@ GET /user
...
@@ -296,6 +302,7 @@ GET /user
"linkedin"
:
""
,
"linkedin"
:
""
,
"twitter"
:
""
,
"twitter"
:
""
,
"website_url"
:
""
,
"website_url"
:
""
,
"organization"
:
""
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"last_sign_in_at"
:
"2012-06-01T11:41:01Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"confirmed_at"
:
"2012-05-23T09:05:22Z"
,
"theme_id"
:
1
,
"theme_id"
:
1
,
...
...
lib/api/entities.rb
View file @
d0b556eb
...
@@ -15,7 +15,7 @@ module API
...
@@ -15,7 +15,7 @@ module API
class
User
<
UserBasic
class
User
<
UserBasic
expose
:created_at
expose
:created_at
expose
:is_admin?
,
as: :is_admin
expose
:is_admin?
,
as: :is_admin
expose
:bio
,
:location
,
:skype
,
:linkedin
,
:twitter
,
:website_url
expose
:bio
,
:location
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:organization
end
end
class
Identity
<
Grape
::
Entity
class
Identity
<
Grape
::
Entity
...
...
lib/api/users.rb
View file @
d0b556eb
...
@@ -60,6 +60,7 @@ module API
...
@@ -60,6 +60,7 @@ module API
# linkedin - Linkedin
# linkedin - Linkedin
# twitter - Twitter account
# twitter - Twitter account
# website_url - Website url
# website_url - Website url
# organization - Organization
# projects_limit - Number of projects user can create
# projects_limit - Number of projects user can create
# extern_uid - External authentication provider UID
# extern_uid - External authentication provider UID
# provider - External provider
# provider - External provider
...
@@ -74,7 +75,7 @@ module API
...
@@ -74,7 +75,7 @@ module API
post
do
post
do
authenticated_as_admin!
authenticated_as_admin!
required_attributes!
[
:email
,
:password
,
:name
,
:username
]
required_attributes!
[
:email
,
:password
,
:name
,
:username
]
attrs
=
attributes_for_keys
[
:email
,
:name
,
:password
,
:skype
,
:linkedin
,
:twitter
,
:projects_limit
,
:username
,
:bio
,
:location
,
:can_create_group
,
:admin
,
:confirm
,
:external
]
attrs
=
attributes_for_keys
[
:email
,
:name
,
:password
,
:skype
,
:linkedin
,
:twitter
,
:projects_limit
,
:username
,
:bio
,
:location
,
:can_create_group
,
:admin
,
:confirm
,
:external
,
:organization
]
admin
=
attrs
.
delete
(
:admin
)
admin
=
attrs
.
delete
(
:admin
)
confirm
=
!
(
attrs
.
delete
(
:confirm
)
=~
/(false|f|no|0)$/i
)
confirm
=
!
(
attrs
.
delete
(
:confirm
)
=~
/(false|f|no|0)$/i
)
user
=
User
.
build_user
(
attrs
)
user
=
User
.
build_user
(
attrs
)
...
@@ -111,6 +112,7 @@ module API
...
@@ -111,6 +112,7 @@ module API
# linkedin - Linkedin
# linkedin - Linkedin
# twitter - Twitter account
# twitter - Twitter account
# website_url - Website url
# website_url - Website url
# organization - Organization
# projects_limit - Limit projects each user can create
# projects_limit - Limit projects each user can create
# bio - Bio
# bio - Bio
# location - Location of the user
# location - Location of the user
...
@@ -122,7 +124,7 @@ module API
...
@@ -122,7 +124,7 @@ module API
put
":id"
do
put
":id"
do
authenticated_as_admin!
authenticated_as_admin!
attrs
=
attributes_for_keys
[
:email
,
:name
,
:password
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:projects_limit
,
:username
,
:bio
,
:location
,
:can_create_group
,
:admin
,
:external
]
attrs
=
attributes_for_keys
[
:email
,
:name
,
:password
,
:skype
,
:linkedin
,
:twitter
,
:website_url
,
:projects_limit
,
:username
,
:bio
,
:location
,
:can_create_group
,
:admin
,
:external
,
:organization
]
user
=
User
.
find
(
params
[
:id
])
user
=
User
.
find
(
params
[
:id
])
not_found!
(
'User'
)
unless
user
not_found!
(
'User'
)
unless
user
...
...
spec/requests/api/users_spec.rb
View file @
d0b556eb
...
@@ -265,6 +265,13 @@ describe API::API, api: true do
...
@@ -265,6 +265,13 @@ describe API::API, api: true do
expect
(
user
.
reload
.
bio
).
to
eq
(
'new test bio'
)
expect
(
user
.
reload
.
bio
).
to
eq
(
'new test bio'
)
end
end
it
"updates user with organization"
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
{
organization:
'GitLab'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'organization'
]).
to
eq
(
'GitLab'
)
expect
(
user
.
reload
.
organization
).
to
eq
(
'GitLab'
)
end
it
'updates user with his own email'
do
it
'updates user with his own email'
do
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
email:
user
.
email
put
api
(
"/users/
#{
user
.
id
}
"
,
admin
),
email:
user
.
email
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
have_http_status
(
200
)
...
...
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