2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Keys
|
|
|
|
class CreateService < ::Keys::BaseService
|
2020-06-23 00:09:42 +05:30
|
|
|
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
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def execute
|
|
|
|
key = user.keys.create(params)
|
|
|
|
notification_service.new_key(key) if key.persisted?
|
|
|
|
key
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
Keys::CreateService.prepend_if_ee('EE::Keys::CreateService')
|