From 83fa59a38c79c02c3489cf8f9f7f34cf4e129467 Mon Sep 17 00:00:00 2001 From: Jeff Webster Date: Sun, 4 Mar 2018 01:07:59 -0500 Subject: [PATCH] MDL-48501 login: update signup_form to use reCAPTCHA v2 --- login/signup_form.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/login/signup_form.php b/login/signup_form.php index 325594b0bbb..89572dbfae8 100644 --- a/login/signup_form.php +++ b/login/signup_form.php @@ -1,5 +1,4 @@ value) of submitted data + * @param array $files array of uploaded files "element_name"=>tmp_file_path + * @return array of "element_name"=>"error_description" if there are errors, + * or an empty array if everything is OK (true allowed for backwards compatibility too). + */ + public function validation($data, $files) { $errors = parent::validation($data, $files); if (signup_captcha_enabled()) { - $recaptcha_element = $this->_form->getElement('recaptcha_element'); - if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) { - $challenge_field = $this->_form->_submitValues['recaptcha_challenge_field']; - $response_field = $this->_form->_submitValues['recaptcha_response_field']; - if (true !== ($result = $recaptcha_element->verify($challenge_field, $response_field))) { + $recaptchaelement = $this->_form->getElement('recaptcha_element'); + if (!empty($this->_form->_submitValues['g-recaptcha-response'])) { + $response = $this->_form->_submitValues['g-recaptcha-response']; + if (!$recaptchaelement->verify($response)) { $errors['recaptcha_element'] = get_string('incorrectpleasetryagain', 'auth'); } } else { @@ -140,7 +146,6 @@ class login_signup_form extends moodleform implements renderable, templatable { $errors += signup_validate_data($data, $files); return $errors; - } /**