ambethia / recaptcha

ReCaptcha helpers for ruby apps

Home Page:http://github.com/ambethia/recaptcha

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

invisible_recaptcha_tags - Redirecting to sessions page upon submission of recaptcha

2f4usteel opened this issue · comments

I followed the documentation to implement invisible_repcatcha_tags on my app but it doesn't seem to work for some reason.

Note: It's a single form.

Here's my setup

# app/views/devise/registrations/new.html.erb

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
   ....
   ....
   <%= invisible_recaptcha_tags ui: :button, text: 'Create Account', id: "sign-up-cta" %><be>
<% end %>
# app/controllers/users/registrations_controller.rb

 prepend_before_action :check_listing_exists, :check_captcha, only: [:create]

 def check_captcha
    return if verify_recaptcha # verify_recaptcha(action: 'signup') for v3

    self.resource = resource_class.new sign_up_params
    resource.validate # Look for any other validation errors besides reCAPTCHA
    set_minimum_password_length

    respond_with_navigational(resource) do
      flash.discard(:recaptcha_error) # We need to discard flash to avoid showing it on the next page reload
      render :new
    end
  end
# routes.rb

devise_for :users, :path => 'account', :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" }, :controllers => { :registrations => "users/registrations", confirmations: 'users/confirmations', sessions: 'users/sessions' }

Upon submission of the recaptcha, it takes me to the login page which is weird. I tried to debug by adding a debugger on #check_captcha but it doesn't seem to reach there.

Can you let me know what could be the issue?

Note: I also tried this tutorial It didn't help me either!

not sure what's wrong there, if you find a solution please update here.