Browse Source

honeypot

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
9fb8fe7df0
  1. 6
      Gemfile.lock
  2. 5
      app/controllers/application_controller.rb
  3. 6
      app/helpers/application_helper.rb
  4. 2
      app/views/devise/registrations/new.html.erb

6
Gemfile.lock

@ -6,7 +6,7 @@ GIT
GIT
remote: https://github.com/activescaffold/active_scaffold.git
revision: da126afef3d59bb0b1e8cbefb6af9186e0146275
revision: 082cf10d1b88c3f2d208480e9841d0468cb8b47f
specs:
active_scaffold (3.1.5)
rails (~> 3.1.0)
@ -94,7 +94,7 @@ GEM
i18n (~> 0.4)
ffi (1.0.9)
fssm (0.2.7)
guard (0.8.6)
guard (0.8.7)
thor (~> 0.14.6)
guard-rspec (0.4.5)
guard (>= 0.4.0)
@ -203,7 +203,7 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.30)
uglifier (1.0.3)
uglifier (1.0.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
warden (1.0.6)

5
app/controllers/application_controller.rb

@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
before_filter :authenticate_user!
include SentientController
protect_from_forgery
before_filter :check_honeypot
rescue_from CanCan::AccessDenied, ActiveScaffold::ActionNotAllowed do |exception|
flash.now[:error] = exception.message
@ -35,4 +36,8 @@ class ApplicationController < ActionController::Base
helper_method :client_remote_ip
helper_method :respond_to
def check_honeypot
render :nothing => true if params[Settings.honeypot].present?
end
end

6
app/helpers/application_helper.rb

@ -37,4 +37,10 @@ module ApplicationHelper
html.html_safe
end
def honeypot
content_tag('div', :style => 'position: absolute; left: -2000px;') do
text_field_tag("#{Settings.honeypot}", nil, :tabindex => 900)
end
end
end

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

@ -7,6 +7,8 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= honeypot %>
<div><%= f.label :first_name %><br />
<%= f.text_field :first_name %></div>

Loading…
Cancel
Save