diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-20 10:24:47 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-20 10:24:47 +0200 |
commit | 3b09e4b0758544ee5247649ee8f1cddd863f869b (patch) | |
tree | 18484a50feb1644f3198bff8a36a67c7df9d3f31 | |
parent | 242e77e070c25fd45896bdd7be6edac4679ec2b2 (diff) | |
download | gitlab-ce-lfs-support-for-ssh-enabled.tar.gz |
Move logic to check ci? or lfs_deploy_token? to Gitlab::Auth::Resultlfs-support-for-ssh-enabled
-rw-r--r-- | app/controllers/projects/git_http_client_controller.rb | 10 | ||||
-rw-r--r-- | app/helpers/lfs_helper.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/auth/result.rb | 12 |
3 files changed, 12 insertions, 12 deletions
diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index ee9ea4bc8b2..cbfd3cab3dd 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -127,15 +127,11 @@ class Projects::GitHttpClientController < Projects::ApplicationController end def ci? - authentication_result.ci? && - authentication_project && - authentication_project == project + authentication_result.ci?(project) end - def lfs_deploy_key? - authentication_result.lfs_deploy_token? && - actor && - actor.projects.include?(project) + def lfs_deploy_token? + authentication_result.lfs_deploy_token?(project) end def authentication_has_download_access? diff --git a/app/helpers/lfs_helper.rb b/app/helpers/lfs_helper.rb index 018ca7d7bba..c15ecc8f86e 100644 --- a/app/helpers/lfs_helper.rb +++ b/app/helpers/lfs_helper.rb @@ -25,7 +25,7 @@ module LfsHelper def lfs_download_access? return false unless project.lfs_enabled? - project.public? || ci? || lfs_deploy_key? || user_can_download_code? || build_can_download_code? + project.public? || ci? || lfs_deploy_token? || user_can_download_code? || build_can_download_code? end def user_can_download_code? diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb index e4786b12676..ab909ebc0d7 100644 --- a/lib/gitlab/auth/result.rb +++ b/lib/gitlab/auth/result.rb @@ -1,12 +1,16 @@ module Gitlab module Auth Result = Struct.new(:actor, :project, :type, :authentication_abilities) do - def ci? - type == :ci + def ci?(for_project) + type == :ci && + project && + project == for_project end - def lfs_deploy_token? - type == :lfs_deploy_token + def lfs_deploy_token?(for_project) + type == :lfs_deploy_token && + actor && + actor.projects.include?(for_project) end def success? |