Skip to content

Commit 85ecbfe

Browse files
Captcha enhancement 01 (#471)
Changes: * Vary the list of Honepot field names * Make timeouts configurable
1 parent d73ff58 commit 85ecbfe

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/controllers/users/registrations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
class Users::RegistrationsController < Devise::RegistrationsController
44
before_action :configure_sign_up_params, only: :create
5-
invisible_captcha honeypot: :terms_and_conditions, only: :create
5+
invisible_captcha only: :create
66

77
protected
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</span>
3636
</div>
3737
</div>
38-
<%= f.invisible_captcha :terms_and_conditions %>
38+
<%= invisible_captcha %>
3939
<div class="actions">
4040
<%= f.submit "Sign Up" %>
4141
</div>

config/initializers/invisible_captcha.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
InvisibleCaptcha.setup do |config|
2-
config.timestamp_enabled = !Rails.env.test?
3-
# config.honeypots << ['more', 'fake', 'attribute', 'names']
4-
# config.visual_honeypots = false
5-
# config.timestamp_threshold = 2
2+
config.honeypots = [:additional_information, :contact_options, :custom, :extra_details, :leave_blank, :optional_data, :other, :phone, :preferred_contact, :secondary_input, :special_instructions, :terms_and_conditions, :web_site]
3+
config.visual_honeypots = ENV['HONEYPOTS_SHOW'].to_s.downcase == 'true' || false
4+
config.timestamp_enabled = ENV['HONEYPOTS_TIMEOUT_ENABLED'] || false
5+
config.timestamp_threshold = ENV['HONEYPOTS_TIMEOUT'].to_i || 2
66
# config.timestamp_enabled = true
77
# config.injectable_styles = false
88
# config.spinner_enabled = true

0 commit comments

Comments
 (0)