Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invisible_recaptcha_tags - Redirecting to sessions page upon submission of recaptcha #411

Open
2f4usteel opened this issue May 17, 2022 · 1 comment

Comments

@2f4usteel
Copy link

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!

@grosser
Copy link
Collaborator

grosser commented May 18, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants