Skip to content
Permalink
Browse files

MDL-48501 login: update signup_form to use reCAPTCHA v2

  • Loading branch information...
jswebster committed Mar 4, 2018
1 parent b526202 commit 17e1f9a22d33e58c90e9d0e77dcef59c0efbdd53
Showing with 13 additions and 8 deletions.
  1. +13 −8 login/signup_form.php
@@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -121,15 +120,22 @@ function definition_after_data(){
}
}
function validation($data, $files) {
/**
* Validate user supplied data on the signup form.
*
* @param array $data array of ("fieldname"=>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 @@ function validation($data, $files) {
$errors += signup_validate_data($data, $files);
return $errors;
}
/**

0 comments on commit 17e1f9a

Please sign in to comment.
You can’t perform that action at this time.