Sha256: 3e9a161ef0bd70ac30667801be7cbdd17a8a58c1cc623f311273244eebb777fe
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'zero-captcha/form_tag_helper' module ZeroCaptcha module SpamProtection def zero_captcha_fields { :_zc_field => '5b5cd0da3121fc53b4bc84d0c8af2e81' } # change this in controller by overriding `zero_captcha_fields` end def protect_from_spam_with_zero_captcha head :ok if zero_captcha_fields.any? { |name, value| params[name] && params[name] != value } end def require_zero_captcha head :ok if zero_captcha_fields.any? { |name, value| !params.has_key?(name) } end def self.included(base) # :nodoc: base.send :helper_method, :zero_captcha_fields if base.respond_to? :before_action base.send :prepend_before_action, :protect_from_spam_with_zero_captcha, :only => [:create, :update] elsif base.respond_to? :before_filter base.send :prepend_before_filter, :protect_from_spam_with_zero_captcha, :only => [:create, :update] end end end end ActionController::Base.send(:include, ZeroCaptcha::SpamProtection) if defined?(ActionController::Base)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zero-captcha-0.0.5 | lib/zero-captcha.rb |