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

Why is one of my forms suddenly visible on live website? #70

Closed
timokleemann opened this issue May 4, 2020 · 5 comments
Closed

Why is one of my forms suddenly visible on live website? #70

timokleemann opened this issue May 4, 2020 · 5 comments
Labels

Comments

@timokleemann
Copy link

timokleemann commented May 4, 2020

I've got a method like this in my Rails 5.2.3 app:

  def guest_account_link
      form_with :url => guest_accounts_path, :local => true do |f|
        concat f.invisible_captcha :title
        concat f.submit "Try now", :data => { :disable_with => false }
      end
  end

class GuestAccountsController < ApplicationController
  invisible_captcha :only               => [:create],
                    :honeypot           => :title,
                    :on_timestamp_spam  => :please_resubmit

The guest_account_link is called from two different locations in the frontend of my app.

Unfortunately, one of them stopped working all of a sudden today (on the live website) and I can't figure out why.

One of the forms still works as expected. In the HTML source code I can see a div with a class title_1588597614. There's also a CSS attribute .title_1588597614 which hides the div.

The other form, however, is completely visible ("If you are a human, ignore this field") and has a class of title_1588598020. When I inspect the source code, I can see that a CSS attribute .title_1588598020 has not been generated and that's why the form is visible and looks so ugly.

What am I missing here and how can this be fixed?

The code used to work for months and hasn't been changed for many weeks, so I am puzzled as to how this could happen.

@markets
Copy link
Owner

markets commented May 4, 2020

Hi @timokleemann 👋

I'll need more info to help you debug this, for example: gem version and settings. Your installation seems fine.

By the way, the most weird thing is:

The code used to work for months and hasn't been changed for many weeks

Do you make an upgrade during this period? During the latest months mostly all changes done are maintenance and stability (https://github.com/markets/invisible_captcha/blob/master/CHANGELOG.md), with no behavior changes for a ~year.

Thanks for reporting, keep in touch.

@timokleemann
Copy link
Author

timokleemann commented May 4, 2020

Hi @markets & thanks for getting back to me so swiftly.

This is an excerpt from my Gemfile.lock file:

    invisible_captcha (1.0.1)
      rails (>= 4.2)

No, as far as I know, I didn't do any upgrades pertaining to invisible_captcha in the last couple of months. I set it up sometime last year and it worked flawlessly ever since. Until today :-(

What could be the reason for one form being hidden and the other one not being hidden?

Apart from the code above, there are no "settings" for invisible_captcha anywhere in my code.

@markets
Copy link
Owner

markets commented May 5, 2020

Hi @timokleemann 👋

What could be the reason for one form being hidden and the other one not being hidden?

Not sure, but if you didn't make any upgrade, this seems related to your app's code or changes on your side. Without seeing the code, it will be really hard for me to debug or give you more info. In case the repo is open source or you can create a minimal app that demonstrates the issue, I'll take a look.

I'm using the gem in several apps (Rails 5 & 6), using the invisible_captcha helper in different views, with no problems.

@timokleemann
Copy link
Author

timokleemann commented May 7, 2020

I couldn't get invisible_captcha to work on both forms. The CSS to hide the honeypot div was always generated for the first form but never for the second. So I simply removed invisible_captcha_styles from the <head> section of my layout file and created my own CSS:

[class^="title_"] {
	display: none;
}

This is the best fix I could find.

@markets
Copy link
Owner

markets commented May 7, 2020

Hi again @timokleemann 👋

Some comments:

  • invisible_captcha_styles is not necessary by default, as styles are injected inline along with the honeypot
  • Without an example app that reproduces the error, it will be almost impossible to debug this
  • If that worked for you and it started failing suddenly without updating the plugin version, this should be related to code changes in your app

I'm going to close it for now, in case you can share with us an example app that demonstrates the error, please re-open and ping me, I'll look at it asap.

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

No branches or pull requests

2 participants