diff options
author | Stan Hu <stanhu@gmail.com> | 2018-11-17 08:59:17 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-11-17 10:18:06 +0300 |
commit | 7be7f570dc9d8bf482d8a1e548b3bd21cccdc39d (patch) | |
tree | 09c3e305a6af2aac3f2ee5eb58e5eba85e124079 /app/services/projects/disable_deploy_key_service.rb | |
parent | 6494467a191f119af31ce3e8d3f32885c1244bdc (diff) |
Fix enabling project deploy key for admins
Admins would be prevented from adding a project deploy key since the
accessible keys would be restricted to the user's keys.
Also backports a spec for DeployKeysController from
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/8432.
Diffstat (limited to 'app/services/projects/disable_deploy_key_service.rb')
-rw-r--r-- | app/services/projects/disable_deploy_key_service.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/services/projects/disable_deploy_key_service.rb b/app/services/projects/disable_deploy_key_service.rb new file mode 100644 index 00000000000..e483c0708c4 --- /dev/null +++ b/app/services/projects/disable_deploy_key_service.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Projects + class DisableDeployKeyService < BaseService + def execute + # rubocop: disable CodeReuse/ActiveRecord + deploy_key_project = project.deploy_keys_projects.find_by(deploy_key_id: params[:id]) + # rubocop: enable CodeReuse/ActiveRecord + + deploy_key_project&.destroy! + end + end +end |