gitlabhq/lib/api/internal.rb
Dmitriy Zaporozhets 935b6ae653 Internal API
2013-02-04 17:53:43 +02:00

25 lines
627 B
Ruby

module Gitlab
# Access API
class Internal < Grape::API
get "/allowed" do
user = User.find_by_username(params[:username])
project = Project.find_with_namespace(params[:project])
action = case params[:action]
when 'git-upload-pack'
then :download_code
when 'git-receive-pack'
then
if project.protected_branch?(params[:ref])
:push_code_to_protected_branches
else
:push_code
end
end
user.can?(action, project)
end
end
end