Commit 15640746 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Refactor _allowed? methods as Rémy asked

parent 3ffa494f
...@@ -128,26 +128,20 @@ class Projects::GitHttpController < Projects::ApplicationController ...@@ -128,26 +128,20 @@ class Projects::GitHttpController < Projects::ApplicationController
end end
def upload_pack_allowed? def upload_pack_allowed?
if !Gitlab.config.gitlab_shell.upload_pack return false unless Gitlab.config.gitlab_shell.upload_pack
false
elsif ci? if user
true
elsif user
Gitlab::GitAccess.new(user, project).download_access_check.allowed? Gitlab::GitAccess.new(user, project).download_access_check.allowed?
else else
project.public? ci? || project.public?
end end
end end
def receive_pack_allowed? def receive_pack_allowed?
if !Gitlab.config.gitlab_shell.receive_pack return false unless Gitlab.config.gitlab_shell.receive_pack
false
elsif user
# Skip user authorization on upload request. # Skip user authorization on upload request.
# It will be done by the pre-receive hook in the repository. # It will be done by the pre-receive hook in the repository.
true user.present?
else
false
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment