add recaptcha for signup process
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -47,6 +47,7 @@ gem 'bootsnap'
|
|||||||
gem 'addressable'
|
gem 'addressable'
|
||||||
gem 'httparty'
|
gem 'httparty'
|
||||||
gem 'rakismet'
|
gem 'rakismet'
|
||||||
|
gem 'recaptcha', require: "recaptcha/rails"
|
||||||
|
|
||||||
# needed for looser jpeg header compat
|
# needed for looser jpeg header compat
|
||||||
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes"
|
gem 'ruby-imagespec', :require => "image_spec", :git => "https://github.com/r888888888/ruby-imagespec.git", :branch => "exif-fixes"
|
||||||
|
|||||||
@@ -278,6 +278,8 @@ GEM
|
|||||||
raindrops (0.17.0)
|
raindrops (0.17.0)
|
||||||
rake (12.0.0)
|
rake (12.0.0)
|
||||||
rakismet (1.5.4)
|
rakismet (1.5.4)
|
||||||
|
recaptcha (4.4.1)
|
||||||
|
json
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
representable (2.3.0)
|
representable (2.3.0)
|
||||||
uber (~> 0.0.7)
|
uber (~> 0.0.7)
|
||||||
@@ -434,6 +436,7 @@ DEPENDENCIES
|
|||||||
radix62 (~> 1.0.1)
|
radix62 (~> 1.0.1)
|
||||||
rails (~> 4.2.0)
|
rails (~> 4.2.0)
|
||||||
rakismet
|
rakismet
|
||||||
|
recaptcha
|
||||||
responders
|
responders
|
||||||
rmagick
|
rmagick
|
||||||
ruby-imagespec!
|
ruby-imagespec!
|
||||||
|
|||||||
@@ -43,12 +43,17 @@ class UsersController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@user = User.new(params[:user], :as => CurrentUser.role)
|
@user = User.new(params[:user], :as => CurrentUser.role)
|
||||||
@user.last_ip_addr = request.remote_ip
|
@user.last_ip_addr = request.remote_ip
|
||||||
@user.save
|
if verify_recaptcha(model: @user)
|
||||||
if @user.errors.empty?
|
@user.save
|
||||||
session[:user_id] = @user.id
|
if @user.errors.empty?
|
||||||
|
session[:user_id] = @user.id
|
||||||
|
end
|
||||||
|
set_current_user
|
||||||
|
respond_with(@user)
|
||||||
|
else
|
||||||
|
flash[:notice] = "Sign up failed"
|
||||||
|
redirect_to new_user_path
|
||||||
end
|
end
|
||||||
set_current_user
|
|
||||||
respond_with(@user)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
<%= f.input :password %>
|
<%= f.input :password %>
|
||||||
<%= f.input :password_confirmation %>
|
<%= f.input :password_confirmation %>
|
||||||
<%= f.button :submit, "Sign up", :data => { :disable_with => "Signing up..." } %>
|
<%= f.button :submit, "Sign up", :data => { :disable_with => "Signing up..." } %>
|
||||||
|
|
||||||
|
<%= recaptcha_tags %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user