Add reCAPTCHA to Users::RegistrationsController#create
This commit is contained in:
parent
47be342228
commit
0f18566c88
2 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
skip_after_action :verify_authorized
|
skip_after_action :verify_authorized
|
||||||
skip_after_action :verify_policy_scoped
|
skip_after_action :verify_policy_scoped
|
||||||
|
|
||||||
|
prepend_before_action :check_captcha, only: :create
|
||||||
|
|
||||||
# before_action :configure_sign_up_params, only: [:create]
|
# before_action :configure_sign_up_params, only: [:create]
|
||||||
# before_action :configure_account_update_params, only: [:update]
|
# before_action :configure_account_update_params, only: [:update]
|
||||||
|
|
||||||
|
@ -67,4 +69,13 @@ protected
|
||||||
def after_update_path_for(_resource)
|
def after_update_path_for(_resource)
|
||||||
edit_user_registration_path
|
edit_user_registration_path
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
<%= f.input :password_confirmation,
|
<%= f.input :password_confirmation,
|
||||||
required: true,
|
required: true,
|
||||||
input_html: { autocomplete: 'new-password' } %>
|
input_html: { autocomplete: 'new-password' } %>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<%= recaptcha_tags %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
|
Reference in a new issue