Sha256: b248fb2cac81d268a509d0814b7733301644333ceb574c70f7d9e7bbffe1fa51
Contents?: true
Size: 879 Bytes
Versions: 13
Compression:
Stored size: 879 Bytes
Contents
require 'httparty' module Locomotive module Steam # This service supports Google Recaptcha or any API compatible with Google class RecaptchaService GOOGLE_API_URL = 'https://www.google.com/recaptcha/api/siteverify'.freeze def initialize(site, request) attributes = site.metafields.values.reduce({}, :merge).with_indifferent_access @api = attributes[:recaptcha_api_url] || GOOGLE_API_URL @secret = attributes[:recaptcha_secret] @ip = request.ip end def verify(response_code) # save a HTTP query if there is no code return false if response_code.blank? _response = HTTParty.get(@api, { query: { secret: @secret, response: response_code, remoteip: @ip }}) _response.parsed_response['success'] end end end end
Version data entries
13 entries across 13 versions & 1 rubygems