adjust for multitenant

This commit is contained in:
Alex Turchyn
2023-06-30 20:31:17 +03:00
parent c904d51302
commit f5caed502f
24 changed files with 139 additions and 52 deletions
+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)