added 260907 version of worker toolkit

This commit is contained in:
2026-09-08 20:30:51 -04:00
parent cbd3f0f8ca
commit 97aca37663
1283 changed files with 142951 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
module Google
class RecaptchaVerifier
def initialize
@secret = ENV["RECAPTCHA_SECRET_KEY"]
@url = "https://www.google.com/recaptcha/api/siteverify"
end
def self.exec(response, remoteip = nil)
new.invoke_service(response, remoteip)
end
def invoke_service(response, remoteip)
params = {
secret: @secret,
response: response,
remoteip: remoteip
}
response = connection.post @url, params
return JSON.parse(response.body)["success"] if response.status.eql?(200)
# FIXME
# rubocop:disable Style/SignalException
fail StandardError, "#{self.class}##{__method__} Got HTTP #{response.status}"
# rubocop:enable Style/SignalException
end
def connection
Faraday.new(headers: {"Accept" => "application/json"})
end
end
end