diff --git a/resources/views/script.blade.php b/resources/views/script.blade.php index 9b8458f..cb1f380 100644 --- a/resources/views/script.blade.php +++ b/resources/views/script.blade.php @@ -13,20 +13,23 @@ .filter((form) => form.dataset.recaptcha === 'true') .forEach((form) => { let action = form.action.includes('://') ? (new URL(form.action)).pathname : form.action; - grecaptcha.execute(site_key, { - action: action + form.addEventListener('submit', (event) => { + event.stopPropagation(); + grecaptcha.execute(site_key, { + action: action .substring(action.indexOf('?'), action.length) .replace(/[^A-z\/_]/gi, '') - }).then((token) => { - if (token) { - let child = document.createElement('input'); - child.setAttribute('type', 'hidden'); - child.setAttribute('name', '_recaptcha'); - child.setAttribute('value', token); - form.appendChild(child); - } + }).then((token) => { + if (token) { + let child = document.createElement('input'); + child.setAttribute('type', 'hidden'); + child.setAttribute('name', '_recaptcha'); + child.setAttribute('value', token); + form.appendChild(child); + } + }); }); }); }; // End Captchavel Script - \ No newline at end of file + diff --git a/src/Http/Middleware/TransparentRecaptcha.php b/src/Http/Middleware/TransparentRecaptcha.php index b19ce2e..fbdd525 100644 --- a/src/Http/Middleware/TransparentRecaptcha.php +++ b/src/Http/Middleware/TransparentRecaptcha.php @@ -2,9 +2,9 @@ namespace DarkGhostHunter\Captchavel\Http\Middleware; -use DarkGhostHunter\Captchavel\Exceptions\InvalidRecaptchaException; -use Illuminate\Http\Request; use ReCaptcha\Response; +use Illuminate\Http\Request; +use DarkGhostHunter\Captchavel\Exceptions\InvalidRecaptchaException; class TransparentRecaptcha extends CheckRecaptcha { @@ -42,8 +42,8 @@ protected function resolve(Request $request, float $threshold) null, now()->toIso8601ZuluString(), null, - (int)$request->query->has('is_robot'), + (int)$request->has('is_robot'), $this->sanitizeAction($request->getRequestUri())) ); } -} \ No newline at end of file +}