fix: test if recaptcha is valid response #388

This commit is contained in:
vnmedeiros 2020-10-21 10:03:45 -03:00
parent 6c40bad791
commit 6ea18b9adc
1 changed files with 2 additions and 2 deletions

View File

@ -1093,8 +1093,8 @@ class REST_Items_Controller extends REST_Controller {
], 400);
}
$secret_key = get_option("tnc_option_recaptch_secret_key");
$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret_key&response=".$captcha_data."&remoteip=".$_SERVER['REMOTE_ADDR']);
if ($response.success) {
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret_key&response=".$captcha_data."&remoteip=".$_SERVER['REMOTE_ADDR']));
if ($response->success) {
return true;
} else {
return new \WP_REST_Response([