adjust for multitenant

This commit is contained in:
Alex Turchyn committed 2023-06-30 22:41:53 +03:00
1 parent c904d51302
commit f5caed502f
24 files changed
+139 -52

No files matched your search

+24
View File
@@ -3,6 +3,30 @@
module Accounts
module_function
def load_signing_certs(account)
certs =
if Docuseal.multitenant?
Docuseal::CERTS
else
EncryptedConfig.find_by(account:, key: EncryptedConfig::ESIGN_CERTS_KEY).value
end
{
cert: OpenSSL::X509::Certificate.new(certs['cert']),
key: OpenSSL::PKey::RSA.new(certs['key']),
sub_ca: OpenSSL::X509::Certificate.new(certs['sub_ca']),
sub_key: OpenSSL::PKey::RSA.new(certs['sub_key']),
root_ca: OpenSSL::X509::Certificate.new(certs['root_ca']),
root_key: OpenSSL::PKey::RSA.new(certs['root_key'])
}
end
def can_send_emails?(account)
return true if Docuseal.multitenant?
EncryptedConfig.exists?(account_id: account.id, key: EncryptedConfig::EMAIL_SMTP_KEY)
end
def normalize_timezone(timezone)
tzinfo = TZInfo::Timezone.get(ActiveSupport::TimeZone::MAPPING[timezone] || timezone)