diff --git a/app/controllers/concerns/remotely_translatable.rb b/app/controllers/concerns/remotely_translatable.rb index 6bbf791d1..7508a29f3 100644 --- a/app/controllers/concerns/remotely_translatable.rb +++ b/app/controllers/concerns/remotely_translatable.rb @@ -26,6 +26,6 @@ module RemotelyTranslatable end def api_key_has_been_set_in_secrets? - Rails.application.secrets.microsoft_api_key.present? + Tenant.current_secrets.microsoft_api_key.present? end end diff --git a/config/secrets.yml.example b/config/secrets.yml.example index 99c821160..a66abb40a 100644 --- a/config/secrets.yml.example +++ b/config/secrets.yml.example @@ -57,7 +57,8 @@ staging: # my_tenant_subdomain: # secret_key: my_secret_value # - # Currently you can overwrite SMTP, SMS and manager settings. + # Currently you can overwrite SMTP, SMS, manager and microsoft API + # settings. <<: *maps <<: *apis @@ -92,7 +93,8 @@ preproduction: # my_tenant_subdomain: # secret_key: my_secret_value # - # Currently you can overwrite SMTP, SMS and manager settings. + # Currently you can overwrite SMTP, SMS, manager and microsoft API + # settings. twitter_key: "" twitter_secret: "" facebook_key: "" @@ -132,7 +134,8 @@ production: # my_tenant_subdomain: # secret_key: my_secret_value # - # Currently you can overwrite SMTP, SMS and manager settings. + # Currently you can overwrite SMTP, SMS, manager and microsoft API + # settings. twitter_key: "" twitter_secret: "" facebook_key: "" diff --git a/lib/remote_translations/microsoft/available_locales.rb b/lib/remote_translations/microsoft/available_locales.rb index 8adee78f7..21ebf05cd 100644 --- a/lib/remote_translations/microsoft/available_locales.rb +++ b/lib/remote_translations/microsoft/available_locales.rb @@ -36,7 +36,7 @@ class RemoteTranslations::Microsoft::AvailableLocales uri = URI(host + path) request = Net::HTTP::Get.new(uri) - request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key + request["Ocp-Apim-Subscription-Key"] = Tenant.current_secrets.microsoft_api_key response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http| http.request(request) diff --git a/lib/remote_translations/microsoft/client.rb b/lib/remote_translations/microsoft/client.rb index d7e1bc5d9..a4b256fda 100644 --- a/lib/remote_translations/microsoft/client.rb +++ b/lib/remote_translations/microsoft/client.rb @@ -6,7 +6,7 @@ class RemoteTranslations::Microsoft::Client PREVENTING_TRANSLATION_KEY = "notranslate".freeze def initialize - api_key = Rails.application.secrets.microsoft_api_key + api_key = Tenant.current_secrets.microsoft_api_key @client = TranslatorText::Client.new(api_key) end