reCaptcha works without javascript now

This commit is contained in:
Amine Ben hammou
2018-01-15 17:41:58 +00:00
parent 6e94db24a2
commit a1ba783264
3 changed files with 24 additions and 7 deletions

View File

@ -90,17 +90,18 @@ class Subscribers extends APIEndpoint {
));
}
if(!empty($recaptcha['enabled']) && !isset($data['recaptcha'])) {
if(!empty($recaptcha['enabled']) && empty($data['recaptcha'])) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please check the captcha.', 'mailpoet')
));
}
if(!empty($recaptcha['enabled'])) {
$res = empty($data['recaptcha']) ? $data['recaptcha-no-js'] : $data['recaptcha'];
$res = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array(
'body' => array(
'secret' => $recaptcha['secret_token'],
'response' => $data['recaptcha']
'response' => $res
)
));
if(is_wp_error($res)) {
@ -125,7 +126,6 @@ class Subscribers extends APIEndpoint {
$segment_ids = $form->filterSegments($segment_ids);
unset($data['segments']);
if(empty($segment_ids)) {
return $this->badRequest(array(
APIError::BAD_REQUEST => __('Please select a list.', 'mailpoet')