Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from DarkGhostHunter/master
Browse files Browse the repository at this point in the history
Minor fixes.
  • Loading branch information
DarkGhostHunter authored Apr 8, 2020
2 parents 6726ec8 + 7010c8b commit 68ff9c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions resources/views/script.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
</script>
</script>
8 changes: 4 additions & 4 deletions src/Http/Middleware/TransparentRecaptcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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()))
);
}
}
}

0 comments on commit 68ff9c9

Please sign in to comment.