2023-05-28 23:20:48 +03:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class EsignSettingsController < ApplicationController
|
|
|
|
|
def create
|
2023-06-24 12:27:34 +03:00
|
|
|
pdfs =
|
2023-07-04 01:58:43 +03:00
|
|
|
params[:files].map do |file|
|
|
|
|
|
HexaPDF::Document.new(io: file.open)
|
2023-06-24 12:27:34 +03:00
|
|
|
end
|
2023-05-28 23:20:48 +03:00
|
|
|
|
2023-06-30 20:31:17 +03:00
|
|
|
certs = Accounts.load_signing_certs(current_account)
|
2023-05-28 23:20:48 +03:00
|
|
|
|
2023-06-30 20:31:17 +03:00
|
|
|
trusted_certs = [certs[:cert], certs[:sub_ca], certs[:root_ca]]
|
2023-05-28 23:20:48 +03:00
|
|
|
|
2023-07-04 01:58:43 +03:00
|
|
|
render turbo_stream: turbo_stream.replace('result', partial: 'result',
|
|
|
|
|
locals: { pdfs:, files: params[:files], trusted_certs: })
|
2023-06-24 12:27:34 +03:00
|
|
|
rescue HexaPDF::MalformedPDFError
|
|
|
|
|
render turbo_stream: turbo_stream.replace('result', html: helpers.tag.div('Invalid PDF', id: 'result'))
|
2023-05-28 23:20:48 +03:00
|
|
|
end
|
|
|
|
|
end
|