summaryrefslogtreecommitdiff
path: root/lib/api/namespaces.rb
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-11-23 14:32:16 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-11-23 17:44:05 +0100
commitdfbfd3c7d7d4677ac99a7f8147a673911e8d4e98 (patch)
tree7dfb3b813f9820fa539eb908dd1ca06719a63348 /lib/api/namespaces.rb
parent5c2578e68177e0b5ba48f9d2931602747ad58c91 (diff)
downloadgitlab-ce-dfbfd3c7d7d4677ac99a7f8147a673911e8d4e98.tar.gz
Allow request namespace by ID or path
Diffstat (limited to 'lib/api/namespaces.rb')
-rw-r--r--lib/api/namespaces.rb18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb
index 21dc5009d0e..32b77aedba8 100644
--- a/lib/api/namespaces.rb
+++ b/lib/api/namespaces.rb
@@ -24,24 +24,10 @@ module API
success Entities::Namespace
end
params do
- requires :id, type: Integer, desc: "Namespace's ID"
+ requires :id, type: String, desc: "Namespace's ID or path"
end
get ':id' do
- namespace = Namespace.find(params[:id])
- authenticate_get_namespace!(namespace)
-
- present namespace, with: Entities::Namespace, current_user: current_user
- end
- end
-
- helpers do
- def authenticate_get_namespace!(namespace)
- return if current_user.admin?
- forbidden!('No access granted') unless user_can_access_namespace?(namespace)
- end
-
- def user_can_access_namespace?(namespace)
- namespace.has_owner?(current_user)
+ present user_namespace, with: Entities::Namespace, current_user: current_user
end
end
end