diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb index 41814ab48..672f41d20 100644 --- a/app/controllers/debates_controller.rb +++ b/app/controllers/debates_controller.rb @@ -1,4 +1,5 @@ class DebatesController < ApplicationController + include RecaptchaHelper before_action :set_debate, only: [:show, :edit, :update] before_action :authenticate_user!, except: [:show, :index] before_action :validate_ownership, only: [:edit, :update] @@ -51,7 +52,7 @@ class DebatesController < ApplicationController end def verify_captcha? - return true unless Rails.application.secrets.recaptcha_public_key + return true unless recaptcha_keys? verify_recaptcha(model: @debate) end diff --git a/app/helpers/recaptcha_helper.rb b/app/helpers/recaptcha_helper.rb new file mode 100644 index 000000000..9e6fa90e6 --- /dev/null +++ b/app/helpers/recaptcha_helper.rb @@ -0,0 +1,8 @@ +module RecaptchaHelper + + def recaptcha_keys? + Recaptcha.configuration.public_key.present? && + Recaptcha.configuration.private_key.present? + end + +end \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0e94e1709..aa8c240b0 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -5,14 +5,13 @@