From ee15b9cabd9142c58d688132839c52652022c8ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrick=20M=C3=BCller?= <p.mueller@pcsg.de>
Date: Thu, 8 Apr 2021 13:28:24 +0200
Subject: [PATCH] fix: reCaptcha V3 -> initial somit onready quiqqer/captcha#10

---
 bin/controls/modules/Google.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/bin/controls/modules/Google.js b/bin/controls/modules/Google.js
index 1eb5e70..ad818ae 100644
--- a/bin/controls/modules/Google.js
+++ b/bin/controls/modules/Google.js
@@ -173,13 +173,17 @@ define('package/quiqqer/captcha/bin/controls/modules/Google', [
         $renderV3: function () {
             var self = this;
 
+            var execute = function() {
+                grecaptcha.execute(self.getAttribute('sitekey'), {action: 'submit'}).then(function (token) {
+                    self.$onCaptchaSuccess(token);
+                });
+            };
+
             grecaptcha.ready(function () {
+                execute();
+
                 // refresh automatically every 120 seconds to prevent timeout
-                setInterval(function () {
-                    grecaptcha.execute(self.getAttribute('sitekey'), {action: 'submit'}).then(function (token) {
-                        self.$onCaptchaSuccess(token);
-                    });
-                }, 120000);
+                setInterval(execute, 120000);
             });
         }
     });
-- 
GitLab