From 1013a2407f7caf603514b433283eb1b4a00e5efe Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 11 Jun 2024 15:52:31 -0400 Subject: [PATCH] Move hcaptcha service config to `config_for` yml --- app/controllers/concerns/auth/captcha_concern.rb | 2 +- app/helpers/admin/settings_helper.rb | 2 +- config/application.rb | 2 ++ config/captcha.yml | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 config/captcha.yml diff --git a/app/controllers/concerns/auth/captcha_concern.rb b/app/controllers/concerns/auth/captcha_concern.rb index cfd93978cea..c01da212499 100644 --- a/app/controllers/concerns/auth/captcha_concern.rb +++ b/app/controllers/concerns/auth/captcha_concern.rb @@ -10,7 +10,7 @@ module Auth::CaptchaConcern end def captcha_available? - ENV['HCAPTCHA_SECRET_KEY'].present? && ENV['HCAPTCHA_SITE_KEY'].present? + Rails.configuration.x.captcha.secret_key.present? && Rails.configuration.x.captcha.site_key.present? end def captcha_enabled? diff --git a/app/helpers/admin/settings_helper.rb b/app/helpers/admin/settings_helper.rb index 6937331e1a6..9b950d5a637 100644 --- a/app/helpers/admin/settings_helper.rb +++ b/app/helpers/admin/settings_helper.rb @@ -2,7 +2,7 @@ module Admin::SettingsHelper def captcha_available? - ENV['HCAPTCHA_SECRET_KEY'].present? && ENV['HCAPTCHA_SITE_KEY'].present? + Rails.configuration.x.captcha.secret_key.present? && Rails.configuration.x.captcha.site_key.present? end def login_activity_title(activity) diff --git a/config/application.rb b/config/application.rb index 3c62a492289..799c00d10da 100644 --- a/config/application.rb +++ b/config/application.rb @@ -112,6 +112,8 @@ module Mastodon end end + config.x.captcha = config_for(:captcha) + config.to_prepare do Doorkeeper::AuthorizationsController.layout 'modal' Doorkeeper::AuthorizedApplicationsController.layout 'admin' diff --git a/config/captcha.yml b/config/captcha.yml new file mode 100644 index 00000000000..a9f54588c71 --- /dev/null +++ b/config/captcha.yml @@ -0,0 +1,3 @@ +shared: + secret_key: <%= ENV.fetch('HCAPTCHA_SECRET_KEY', nil) %> + site_key: <%= ENV.fetch('HCAPTCHA_SITE_KEY', nil) %>