Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
added recaptcha to registration (refs https://trello.com/c/ibtynmhI/5…
Browse files Browse the repository at this point in the history
  • Loading branch information
nutsoriginal committed Feb 21, 2017
1 parent 047dd42 commit 19d7659
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ gem 'compass-rails', '2.0.0'
gem 'haml_coffee_assets'
gem 'execjs'

gem 'recaptcha', require: 'recaptcha/rails'

group :test, :development do
gem 'sqlite3'
gem 'pre-commit'
Expand Down
5 changes: 4 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ GEM
activesupport (>= 3.0)
i18n
polyamorous (~> 1.1)
recaptcha (4.1.0)
json
redcarpet (3.2.2)
redis (3.2.0)
redis-namespace (1.5.1)
Expand Down Expand Up @@ -548,6 +550,7 @@ DEPENDENCIES
rails (~> 4.2.0)
rake
ransack
recaptcha
redcarpet
responders (~> 2.0)
resque
Expand Down Expand Up @@ -578,4 +581,4 @@ DEPENDENCIES
wrong

BUNDLED WITH
1.13.6
1.14.3
2 changes: 1 addition & 1 deletion app/controllers/web/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def activate
def create
@user = UserRegistrationType.new params[:user]
@user.show_as_participant = true
if @user.save
if verify_recaptcha(model: @user) && @user.save
User::PromoCode.create({ code: generate_promo_code, user_id: @user.id })
@user.activate
sign_in @user
Expand Down
2 changes: 2 additions & 0 deletions app/views/web/users/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
= f.input :password, input_html: {class: "input_type-1"}, placeholder: "Придумайте пароль"
%li.form__element
= f.input :password_confirmation, required: true, input_html: {class: "input_type-1"}, placeholder: "Повторите пароль"
%li.form__element
= recaptcha_tags
%li.privacy_politics
%input#privacy.checkbox_type-1{ name: "privacy_order", type: "checkbox" }
%label.privacy_checkbox{ for: "privacy" }
Expand Down
6 changes: 6 additions & 0 deletions config/initializers/recaptcha.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Recaptcha.configure do |config|
config.site_key = '6LeANRYUAAAAAPvpOBUiRVXKkGJU-ZPjfL4pBMEl'
config.secret_key = '6LeANRYUAAAAAAjp5BjWyyeQRbUgY98crfiCqYpq'
# Uncomment the following line if you are using a proxy server:
# config.proxy = 'http://myproxy.com.au:8080'
end

0 comments on commit 19d7659

Please sign in to comment.