mirror of
https://github.com/neocities/neocities.git
synced 2025-05-15 08:57:17 +02:00
switch to captcha v2 api
This commit is contained in:
parent
7b0c26c1c2
commit
dae2466487
9 changed files with 29 additions and 45 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue