Module: Rack::Attack::Recaptcha

Defined in:
lib/rack/attack/recaptcha.rb,
lib/rack/attack/recaptcha/version.rb,
lib/rack/attack/recaptcha/client_helper.rb,
lib/rack/attack/recaptcha/verification_helper.rb

Defined Under Namespace

Modules: ClientHelper, VerificationHelper

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



27
28
29
# File 'lib/rack/attack/recaptcha.rb', line 27

def call(env)
  @rack_attack.call(env)
end

.new(app) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rack/attack/recaptcha.rb', line 11

def new(app)
  @default_response = Rack::Attack.throttled_response
  @rack_attack = Rack::Attack.new(app).tap { |attack|
    attack.class.throttled_response = lambda { |env|
      if env["rack.attack.match_type"] == :recaptcha
        env["rack.attack.use_recaptcha"] = true
        app
      else
        @default_response
      end.call(env)
    }
  }

  self
end