diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index b3ebd92..1f8d0f9 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -4,6 +4,8 @@ class Users::RegistrationsController < Devise::RegistrationsController skip_after_action :verify_authorized skip_after_action :verify_policy_scoped + prepend_before_action :check_captcha, only: :create + # before_action :configure_sign_up_params, only: [:create] # before_action :configure_account_update_params, only: [:update] @@ -67,4 +69,13 @@ protected def after_update_path_for(_resource) edit_user_registration_path end + + def check_captcha + return if verify_recaptcha + + self.resource = resource_class.new sign_up_params + resource.validate + set_minimum_password_length + render :new + end end diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index 855302f..564751c 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -16,6 +16,10 @@ <%= f.input :password_confirmation, required: true, input_html: { autocomplete: 'new-password' } %> + +
+ <%= recaptcha_tags %> +