debian-mirror-gitlab/app/services/keys/create_service.rb
2020-06-23 00:09:42 +05:30

22 lines
527 B
Ruby

# frozen_string_literal: true
module Keys
class CreateService < ::Keys::BaseService
attr_accessor :current_user
def initialize(current_user, params = {})
@current_user, @params = current_user, params
@ip_address = @params.delete(:ip_address)
@user = params.delete(:user) || current_user
end
def execute
key = user.keys.create(params)
notification_service.new_key(key) if key.persisted?
key
end
end
end
Keys::CreateService.prepend_if_ee('EE::Keys::CreateService')