Skip to content

Commit

Permalink
integrate invisible_captcha gem in sign-up form
Browse files Browse the repository at this point in the history
  • Loading branch information
markets committed May 1, 2024
1 parent de9d580 commit 5c19f88
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem 'pg', '~> 1.4'
gem 'json_translate', '~> 4.0.0'
gem 'devise', '~> 4.9.1'
gem 'devise-i18n', '~> 1.11.0'
gem 'invisible_captcha', '~> 2.3.0'
gem 'http_accept_language', '~> 2.1.1'
gem 'kaminari', '~> 1.2.1'
gem 'simple_form', '~> 5.0.2'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ GEM
has_scope (>= 0.6)
railties (>= 6.0)
responders (>= 2)
invisible_captcha (2.3.0)
rails (>= 5.2)
jmespath (1.6.2)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
Expand Down Expand Up @@ -450,6 +452,7 @@ DEPENDENCIES
has_scope (~> 0.7.2)
http_accept_language (~> 2.1.1)
image_processing (~> 1.12)
invisible_captcha (~> 2.3.0)
jquery-rails (~> 4.4.0)
json_translate (~> 4.0.0)
kaminari (~> 1.2.1)
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class UsersController < ApplicationController
before_action :user_should_be_confirmed, except: %i[signup create please_confirm]
before_action :member_should_exist_and_be_active, except: %i[signup create edit show update please_confirm]

invisible_captcha if: -> { params[:from_signup].present? }

has_scope :tagged_with, as: :tag

def index
Expand Down
1 change: 1 addition & 0 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<%= show_error_messages!(@user) %>
<%= simple_form_for @user do |f| %>
<%= f.hidden_field :locale, value: I18n.locale %>
<%= invisible_captcha %>

<div class="form-inputs">
<%= f.input :username %>
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/invisible_captcha.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
InvisibleCaptcha.setup do |config|
config.timestamp_enabled = !Rails.env.test?
config.spinner_enabled = !Rails.env.test?
end

0 comments on commit 5c19f88

Please sign in to comment.