From 65f491325e625e8848a8eabb0a7d3a1b38347b94 Mon Sep 17 00:00:00 2001 From: DocuSeal Date: Sat, 28 Oct 2023 00:42:17 +0300 Subject: [PATCH] adjust configs loading --- app/controllers/verify_pdf_signature_controller.rb | 2 +- lib/accounts.rb | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/controllers/verify_pdf_signature_controller.rb b/app/controllers/verify_pdf_signature_controller.rb index 49d9e44a..26bcdcc5 100644 --- a/app/controllers/verify_pdf_signature_controller.rb +++ b/app/controllers/verify_pdf_signature_controller.rb @@ -12,7 +12,7 @@ class VerifyPdfSignatureController < ApplicationController cert_data = if Docuseal.multitenant? Docuseal::CERTS else - EncryptedConfig.find_by(account: current_account, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {} + EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || {} end default_pkcs = GenerateCertificate.load_pkcs(cert_data) diff --git a/lib/accounts.rb b/lib/accounts.rb index 1a73c459..f9679ce4 100644 --- a/lib/accounts.rb +++ b/lib/accounts.rb @@ -47,7 +47,7 @@ module Accounts end 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) end @@ -57,8 +57,7 @@ module Accounts if Docuseal.multitenant? EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY)&.value || Docuseal::CERTS else - EncryptedConfig.find_by(account: Account.order(:id).first, - key: EncryptedConfig::ESIGN_CERTS_KEY).value + EncryptedConfig.find_by(key: EncryptedConfig::ESIGN_CERTS_KEY).value end if (default_cert = cert_data['custom']&.find { |e| e['status'] == 'default' }) @@ -68,11 +67,11 @@ module Accounts end end - def can_send_emails?(account) + def can_send_emails?(_account) return true if Docuseal.multitenant? 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 def normalize_timezone(timezone)