Class: Turnstiled::Verifier
- Inherits:
-
Object
- Object
- Turnstiled::Verifier
- Defined in:
- lib/turnstiled/verifier.rb
Instance Method Summary collapse
Instance Method Details
#client ⇒ Object
17 18 19 20 21 22 |
# File 'lib/turnstiled/verifier.rb', line 17 def client @client ||= Faraday.new() do |f| f.request :json f.response :json end end |
#client_options ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/turnstiled/verifier.rb', line 24 def { url: "https://challenges.cloudflare.com/turnstile/v0", request: { timeout: 3 } } end |
#verify(request) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/turnstiled/verifier.rb', line 5 def verify(request) return request.params["cf-turnstile-response"] == "1" if Turnstiled.mock response = client.post("siteverify", { secret: Turnstiled.site_secret, response: request.params["cf-turnstile-response"], remoteip: request.remote_ip }) response.body.fetch("success", false) end |