gitlab-org--gitlab-foss/app/services/projects/enable_deploy_key_service.rb
2016-08-08 20:59:51 +02:00

17 lines
323 B
Ruby

module Projects
class EnableDeployKeyService < BaseService
def execute
key = accessible_keys.find_by(id: params[:key_id] || params[:id])
return unless key
project.deploy_keys << key
key
end
private
def accessible_keys
current_user.accessible_deploy_keys
end
end
end