diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-11 15:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-08-11 15:09:19 +0300 |
commit | 30f9120ba63ea54283c34a046de691a3dbf59450 (patch) | |
tree | 5ff9502c877d088e8985cf6636d1a5566accf540 /app/finders | |
parent | 34facbbce9531f6c9a0ca8e4eaa112e4cd3d7e06 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/autocomplete/deploy_keys_with_write_access_finder.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb b/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb new file mode 100644 index 00000000000..a123a0dc4f0 --- /dev/null +++ b/app/finders/autocomplete/deploy_keys_with_write_access_finder.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Autocomplete + # Finder for retrieving deploy keys to use for autocomplete data sources. + class DeployKeysWithWriteAccessFinder + attr_reader :current_user, :project + + def initialize(current_user, project) + @current_user = current_user + @project = project + end + + def execute + return DeployKey.none if project.nil? + + raise Gitlab::Access::AccessDeniedError unless current_user.can?(:admin_project, project) + + project.deploy_keys.merge(DeployKeysProject.with_write_access) + end + end +end |