adjust configs loading

pull/133/head
DocuSeal 2 years ago
parent 57aef5f5e5
commit 65f491325e

@ -12,7 +12,7 @@ class VerifyPdfSignatureController < ApplicationController
cert_data = if Docuseal.multitenant? cert_data = if Docuseal.multitenant?
Docuseal::CERTS Docuseal::CERTS
else else
EncryptedConfig.find_by(account: current_account, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {} EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {}
end end
default_pkcs = GenerateCertificate.load_pkcs(cert_data) default_pkcs = GenerateCertificate.load_pkcs(cert_data)

@ -47,7 +47,7 @@ module Accounts
end end
def load_webhook_configs(account) def load_webhook_configs(account)
account = Account.order(:id).first unless Docuseal.multitenant? EncryptedConfig.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) unless Docuseal.multitenant?
account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY) account.encrypted_configs.find_by(key: EncryptedConfig::WEBHOOK_URL_KEY)
end end
@ -57,8 +57,7 @@ module Accounts
if Docuseal.multitenant? if Docuseal.multitenant?
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || Docuseal::CERTS EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || Docuseal::CERTS
else else
EncryptedConfig.find_by(account: Account.order(:id).first, EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value
key: EncryptedConfig::ESIGN_CERTS_KEY).value
end end
if (default_cert = cert_data['custom']&.find { |e| e['status'] == 'default' }) if (default_cert = cert_data['custom']&.find { |e| e['status'] == 'default' })
@ -68,11 +67,11 @@ module Accounts
end end
end end
def can_send_emails?(account) def can_send_emails?(_account)
return true if Docuseal.multitenant? return true if Docuseal.multitenant?
return true if ENV['SMTP_ADDRESS'].present? return true if ENV['SMTP_ADDRESS'].present?
EncryptedConfig.exists?(account_id: account.id, key: EncryptedConfig::EMAIL_SMTP_KEY) EncryptedConfig.exists?(key: EncryptedConfig::EMAIL_SMTP_KEY)
end end
def normalize_timezone(timezone) def normalize_timezone(timezone)

Loading…
Cancel
Save