fix recaptcha validation

This commit is contained in:
Amine Ben hammou
2017-12-19 10:38:08 +00:00
parent 5e5caab4da
commit 99a007fb70

View File

@ -103,7 +103,13 @@ class Subscribers extends APIEndpoint {
'response' => $data['recaptcha'] 'response' => $data['recaptcha']
) )
)); ));
if(is_wp_error($res) || !$res['body']['success']) { if(is_wp_error($res)) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Error while validating the reCAPTCHA.', 'mailpoet')
));
}
$res = json_decode($res['body']);
if(!$res->success) {
return $this->badRequest(array( return $this->badRequest(array(
APIError::BAD_REQUEST => __('Error while validating the reCAPTCHA.', 'mailpoet') APIError::BAD_REQUEST => __('Error while validating the reCAPTCHA.', 'mailpoet')
)); ));