From c98f89eac7e2ebf6af4f242d94253c1260517f39 Mon Sep 17 00:00:00 2001 From: Patricio Cano <suprnova32@gmail.com> Date: Wed, 22 Jun 2016 13:08:02 -0500 Subject: [PATCH] Simplify access checks --- app/controllers/projects/git_http_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb index 79a7e61e3fe..f124333bd5b 100644 --- a/app/controllers/projects/git_http_controller.rb +++ b/app/controllers/projects/git_http_controller.rb @@ -162,12 +162,18 @@ class Projects::GitHttpController < Projects::ApplicationController return false unless Gitlab.config.gitlab_shell.upload_pack if user - Gitlab::GitAccess.new(user, project, 'http').download_access_check.allowed? + access.allowed? else ci? || project.public? end end + def access + return @access if defined?(@access) + + @access = Gitlab::GitAccess.new(user, project, 'http').check('git-upload-pack') + end + def receive_pack_allowed? return false unless Gitlab.config.gitlab_shell.receive_pack -- GitLab