summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2016-06-03 15:28:35 +0200
committerJacob Vosmaer <jacob@gitlab.com>2016-06-03 15:28:35 +0200
commit1564074648afc12fc788a7b5e2eb896dc74f62ef (patch)
tree6f33631017d6bfe1bcb15ed484168d422a76ae18 /app/controllers
parent3ffa494ffe06105d6e36a46df52e8a842be0ab69 (diff)
downloadgitlab-ce-1564074648afc12fc788a7b5e2eb896dc74f62ef.tar.gz
Refactor _allowed? methods as Rémy asked
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/git_http_controller.rb24
1 files changed, 9 insertions, 15 deletions
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 5dfa10d218e..bf7ba7a5829 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -128,26 +128,20 @@ class Projects::GitHttpController < Projects::ApplicationController
end
def upload_pack_allowed?
- if !Gitlab.config.gitlab_shell.upload_pack
- false
- elsif ci?
- true
- elsif user
+ return false unless Gitlab.config.gitlab_shell.upload_pack
+
+ if user
Gitlab::GitAccess.new(user, project).download_access_check.allowed?
else
- project.public?
+ ci? || project.public?
end
end
def receive_pack_allowed?
- if !Gitlab.config.gitlab_shell.receive_pack
- false
- elsif user
- # Skip user authorization on upload request.
- # It will be done by the pre-receive hook in the repository.
- true
- else
- false
- end
+ return false unless Gitlab.config.gitlab_shell.receive_pack
+
+ # Skip user authorization on upload request.
+ # It will be done by the pre-receive hook in the repository.
+ user.present?
end
end