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

Recaptcha v2 always false. Rails 7 #457

Open
Heahmund opened this issue Oct 31, 2024 · 0 comments
Open

Recaptcha v2 always false. Rails 7 #457

Heahmund opened this issue Oct 31, 2024 · 0 comments

Comments

@Heahmund
Copy link

Heahmund commented Oct 31, 2024

I tried to add recaptcha on site. I use recaptcha v3 and if it false then i add v2 to the form with remote: true.
like that:
$("#captcha-v2-<%= @modal %>").html("<%= j recaptcha_tags(site_key: Rails.application.credentials.recaptcha_v2['site_key']) %>");
However v3 works fine, but v2 always false.

my controller looks like that:

  def send_callback_email
    callback = params[:callback]
    @action = params["action"]
    @modal = "callback"
    v3_secret = Rails.application.credentials.recaptcha_v3['secret_key']
    v2_secret = Rails.application.credentials.recaptcha_v2['secret_key']
    @success = verify_recaptcha(action: @action, minimum_score: 0.7, secret_key: v3_secret) ||
               verify_recaptcha(secret_key: v2_secret)
    if @success && callback[:agreement]
      ClientServiceMailer.callback_email(callback[:callback_client_name], callback[:callback_client_phone]).deliver_now
    end
    render "mailer_reply"
  end

what i tried:
i add grecaptcha.reset() But i think it is useless cause js create a new recaptcha every time after fail. So i add it just incase.
Also i tried to do form without remote true.
I checked keys and tried to do the same as in example. I do not want to use Stimulus and turbo for my site, but i added them for test.
And i tried to create another pair of keys, just incase something is wrong with mine, and i tried to use google test keys.
I tried hCaptcha too, but it leads to error for executeRecaptchaFor....
And anyway recaptcha is false. I have no idea why is that happening. Do anyone know what`s wrong?

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

1 participant