debian-mirror-gitlab/app/services/projects/enable_deploy_key_service.rb

21 lines
383 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module Projects
class EnableDeployKeyService < BaseService
def execute
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
return unless key
2017-08-17 22:00:37 +05:30
unless project.deploy_keys.include?(key)
project.deploy_keys << key
end
2016-09-13 17:45:13 +05:30
key
end
private
def accessible_keys
current_user.accessible_deploy_keys
end
end
end