From 4afe9a791b123b33abf7739295ac7088d4718719 Mon Sep 17 00:00:00 2001 From: Geoffrey Date: Tue, 29 Sep 2020 17:05:31 +1300 Subject: [PATCH] Update Submissions.class.php Enable the reCaptcha check so that if there's no g-recaptcha-response but the reCaptcha config is set, reCaptcha is required. --- src/global/code/Submissions.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/global/code/Submissions.class.php b/src/global/code/Submissions.class.php index 43941df6..0c270cd6 100644 --- a/src/global/code/Submissions.class.php +++ b/src/global/code/Submissions.class.php @@ -80,10 +80,9 @@ public static function processFormSubmission($form_data) exit; } - // was there a reCAPTCHA response? If so, a recaptcha was just submitted. This generally implies the - // form page included the API, so check it was entered correctly. If not, return the user to the webpage - if (isset($api_enabled) && isset($form_data["g-recaptcha-response"])) { - + // Are the reCaptcha config variables set? If so, a recaptcha is required so check it is valid. + // If not, return the user to the webpage. + if (isset($api_enabled) && ! empty(Core::getAPIRecaptchaSecretKey()) && ! empty(Core::getApiRecaptchaSiteKey())) { $api = new API(array("init_core" => false)); $api->includeRecaptchaLib(); $resp = $api->validateRecaptcha($form_data["g-recaptcha-response"]);