diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-04 15:59:17 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-04 15:59:17 +0000 |
commit | b9219469f759f387a35bec39c3dc59477793ef1b (patch) | |
tree | c6f97d7545fd6d44d041b3192974e325dee01854 /lib | |
parent | 1d945945bb66871dcebefef5824740c823fd7b09 (diff) | |
parent | 67992b9be6fc19ef4cc06de48995d1ee9617049a (diff) | |
download | gitlab-ce-b9219469f759f387a35bec39c3dc59477793ef1b.tar.gz |
Merge branch 'make-namespaces-api-available-to-all-users' into 'master'
Make namespace API available to all users
### What does this MR do?
This MR makes it possible for a user to query namespaces to which he/she has access. Also, it adds documentation for the existing API.
### Why was this MR needed?
Even though the `groups` API exists, it might still be useful to have an endpoint that tells the namespace type (e.g. `user` vs. `group`), especially if a user has access to a number of different projects.
### What are the relevant issue numbers?
Closes https://github.com/gitlabhq/gitlabhq/issues/9328
See merge request !708
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/namespaces.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb index b90ed6af5fb..50d3729449e 100644 --- a/lib/api/namespaces.rb +++ b/lib/api/namespaces.rb @@ -1,10 +1,7 @@ module API # namespaces API class Namespaces < Grape::API - before do - authenticate! - authenticated_as_admin! - end + before { authenticate! } resource :namespaces do # Get a namespaces list @@ -12,7 +9,11 @@ module API # Example Request: # GET /namespaces get do - @namespaces = Namespace.all + @namespaces = if current_user.admin + Namespace.all + else + current_user.namespaces + end @namespaces = @namespaces.search(params[:search]) if params[:search].present? @namespaces = paginate @namespaces |