Commit 795acf2e authored by Kamil Trzcinski's avatar Kamil Trzcinski

Move logic to check ci? or lfs_deploy_token? to Gitlab::Auth::Result

parent 242e77e0
...@@ -127,15 +127,11 @@ class Projects::GitHttpClientController < Projects::ApplicationController ...@@ -127,15 +127,11 @@ class Projects::GitHttpClientController < Projects::ApplicationController
end end
def ci? def ci?
authentication_result.ci? && authentication_result.ci?(project)
authentication_project &&
authentication_project == project
end end
def lfs_deploy_key? def lfs_deploy_token?
authentication_result.lfs_deploy_token? && authentication_result.lfs_deploy_token?(project)
actor &&
actor.projects.include?(project)
end end
def authentication_has_download_access? def authentication_has_download_access?
......
...@@ -25,7 +25,7 @@ module LfsHelper ...@@ -25,7 +25,7 @@ module LfsHelper
def lfs_download_access? def lfs_download_access?
return false unless project.lfs_enabled? 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 end
def user_can_download_code? def user_can_download_code?
......
module Gitlab module Gitlab
module Auth module Auth
Result = Struct.new(:actor, :project, :type, :authentication_abilities) do Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
def ci? def ci?(for_project)
type == :ci type == :ci &&
project &&
project == for_project
end end
def lfs_deploy_token? def lfs_deploy_token?(for_project)
type == :lfs_deploy_token type == :lfs_deploy_token &&
actor &&
actor.projects.include?(for_project)
end end
def success? def success?
......
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