switch to captcha v2 api

This commit is contained in:
Kyle Drake 2018-02-21 09:29:00 -08:00
parent 7b0c26c1c2
commit dae2466487
9 changed files with 29 additions and 45 deletions

View file

@ -122,3 +122,21 @@ end
def flash_display(opts={})
erb :'_flash', layout: false, locals: {opts: opts}
end
def recaptcha_valid?
return true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS']
return false unless params[:'g-recaptcha-response']
resp = Net::HTTP.get URI(
'https://www.google.com/recaptcha/api/siteverify?'+
Rack::Utils.build_query(
secret: $config['recaptcha_private_key'],
response: params[:'g-recaptcha-response']
)
)
if JSON.parse(resp)['success'] == true
true
else
false
end
end