fixes for hcaptcha, add to dmca form

This commit is contained in:
Kyle Drake 2020-11-26 01:45:23 -06:00
parent 79cdd06b19
commit 2821f513f1
9 changed files with 32 additions and 25 deletions

View file

@ -135,3 +135,24 @@ def recaptcha_valid?
false
end
end
def hcaptcha_valid?
return true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS']
return false unless params[:'h-captcha-response']
resp = Net::HTTP.get URI(
'https://hcaptcha.com/siteverify?'+
Rack::Utils.build_query(
secret: $config['hcaptcha_secret_key'],
response: params[:'h-captcha-response']
)
)
resp = JSON.parse resp
if resp['success'] == true
true
else
false
end
end