class Locomotive::Steam::RecaptchaService
This service supports Google Recaptcha or any API compatible with Google
Constants
- GOOGLE_API_URL
Public Class Methods
new(site, request)
click to toggle source
# File lib/locomotive/steam/services/recaptcha_service.rb, line 11 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
Public Instance Methods
verify(response_code)
click to toggle source
# File lib/locomotive/steam/services/recaptcha_service.rb, line 19 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