[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] Resolve session persistence issue in registration form

"Victor Emanouilov \(@kroky\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69eb4777f7c6_3818eb1031888@gitlab-sidekiq-low-urgency-cpu-bound-v2-d58b9958b-svqfs.mail>

Victor Emanouilov pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki


Commits:
de9c6149 by Elifeleti Mukisa Dan at 2026-04-24T10:27:57+00:00
[BP][FIX] Resolve session persistence issue in registration form
---
* [BP][FIX] Resolve session persistence issue in registration form
---
* [FIX] Resolve session persistence issue in registration form
---
* [FIX] Store captcha validation by ID only to prevent token consumption issues in registration

* [FIX] Resolve captcha validation issues in registration process(register module)

* [FIX] phpcs errors

* [FIX] Resolve session persistence issue in registration form

See merge request tikiwiki/tiki!6923

See merge request tikiwiki/tiki!7671

See merge request tikiwiki/tiki!10065

- - - - -


2 changed files:

- lib/captcha/captchalib.php
- lib/smarty_tiki/FunctionHandler/UserRegistration.php


Changes:

=====================================
lib/captcha/captchalib.php
=====================================
@@ -223,6 +223,19 @@ Recaptcha.create("' . $this->captcha->getSiteKey() . '",
         if (is_null($input)) {
             $input = $_REQUEST;
         }
+
+        // Check session for previously validated captcha
+        $captchaId = null;
+        if (isset($input['captcha']) && isset($input['captcha']['id'])) {
+            $captchaId = $input['captcha']['id'];
+
+            // Check if this captcha ID was already validated
+            $validatedKey = 'captcha_validated_' . $captchaId;
+            if (isset($_SESSION[$validatedKey]) && $_SESSION[$validatedKey] === true) {
+                return true;
+            }
+        }
+
         if (in_array($this->type, ['recaptcha', 'recaptcha20', 'recaptcha30'])) {
             // Temporary workaround of zend/http client uses arg_separator.output for making POST request body
             // which fails with Google recaptcha services if used with '&amp;' value
@@ -232,7 +245,6 @@ Recaptcha.create("' . $this->captcha->getSiteKey() . '",
             ini_set('arg_separator.output', '&');
             $result = $this->captcha->isValid($input);
             ini_set('arg_separator.output', $oldVal);
-            return $result;
         } else {
             if (isset($input['captcha'])) {
                 $captchaInput = $input['captcha'];
@@ -240,9 +252,15 @@ Recaptcha.create("' . $this->captcha->getSiteKey() . '",
                 global $jitPost;
                 $captchaInput = $jitPost->captcha->asArray();
             }
+            $result = $this->captcha->isValid($captchaInput);
+        }
 
-            return $this->captcha->isValid($captchaInput);
+        // Store validation result in session if successful
+        if ($result && $captchaId) {
+            $validatedKey = 'captcha_validated_' . $captchaId;
+            $_SESSION[$validatedKey] = true;
         }
+        return $result;
     }
 
     /**


=====================================
lib/smarty_tiki/FunctionHandler/UserRegistration.php
=====================================
@@ -23,7 +23,10 @@ class UserRegistration extends Base
         $captchalib = TikiLib::lib('captcha');
         $access = TikiLib::lib('access');
 
-        $captchalib->generate();
+        // Only generate captcha if this is not a form submission
+        if (! isset($_REQUEST['register'])) {
+            $captchalib->generate();
+        }
 
         if ($prefs['allowRegister'] != 'y') {
             return;



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/de9c614982dc70eed102495355bd95afe8925ae1

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/de9c614982dc70eed102495355bd95afe8925ae1
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.