2020-10-12 07:33:49 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Form::IpBlockBatch
|
|
|
|
include ActiveModel::Model
|
|
|
|
include Authorization
|
|
|
|
include AccountableConcern
|
|
|
|
|
|
|
|
attr_accessor :ip_block_ids, :action, :current_account
|
|
|
|
|
|
|
|
def save
|
|
|
|
case action
|
|
|
|
when 'delete'
|
|
|
|
delete!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def ip_blocks
|
|
|
|
@ip_blocks ||= IpBlock.where(id: ip_block_ids)
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete!
|
2023-10-16 07:36:28 -07:00
|
|
|
verify_authorization(:destroy?)
|
2020-10-12 07:33:49 -07:00
|
|
|
|
|
|
|
ip_blocks.each do |ip_block|
|
|
|
|
ip_block.destroy
|
|
|
|
log_action :destroy, ip_block
|
|
|
|
end
|
|
|
|
end
|
2023-10-16 07:36:28 -07:00
|
|
|
|
|
|
|
def verify_authorization(permission)
|
|
|
|
ip_blocks.each { |ip_block| authorize(ip_block, permission) }
|
|
|
|
end
|
2020-10-12 07:33:49 -07:00
|
|
|
end
|