diff options
Diffstat (limited to 'lib/api/namespaces.rb')
-rw-r--r-- | lib/api/namespaces.rb | 18 |
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 |