mirror of
https://github.com/dyzulk/trustlab-api.git
synced 2026-01-26 13:22:05 +07:00
First commit
This commit is contained in:
0
resources/views/vendor/cloudflare-turnstile/.gitkeep
vendored
Normal file
0
resources/views/vendor/cloudflare-turnstile/.gitkeep
vendored
Normal file
1
resources/views/vendor/cloudflare-turnstile/components/scripts.blade.php
vendored
Normal file
1
resources/views/vendor/cloudflare-turnstile/components/scripts.blade.php
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer {{ $attributes }}></script>
|
||||
45
resources/views/vendor/cloudflare-turnstile/components/turnstile.blade.php
vendored
Normal file
45
resources/views/vendor/cloudflare-turnstile/components/turnstile.blade.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
@props([
|
||||
'id' => 'captcha',
|
||||
])
|
||||
|
||||
@php
|
||||
if (! preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $id)) {
|
||||
throw new InvalidArgumentException("The Turnstile ID [{$id}] must start with a letter or underscore, and can only contain alphanumeric or underscore characters.");
|
||||
}
|
||||
|
||||
$model = $attributes->has('wire:model') ? $attributes->get('wire:model') : null;
|
||||
@endphp
|
||||
|
||||
<div
|
||||
data-sitekey="{{ config('services.turnstile.key') }}"
|
||||
@if ($model)
|
||||
wire:ignore
|
||||
data-callback="{{ $id }}Callback"
|
||||
data-expired-callback="{{ $id }}ExpiredCallback"
|
||||
data-timeout-callback="{{ $id }}ExpiredCallback"
|
||||
{{ $attributes->filter(fn($value, $key) => ! in_array($key, ['data-callback', 'data-expired-callback', 'data-timeout-callback', 'wire:model', 'id']))->class(['cf-turnstile']) }}
|
||||
@else
|
||||
{{ $attributes->class(['cf-turnstile']) }}
|
||||
@endif
|
||||
></div>
|
||||
|
||||
@if ($model)
|
||||
<script>
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
window.{{ $id }}Callback = function (token) {
|
||||
@this.set("{{ $model }}", token);
|
||||
}
|
||||
|
||||
window.{{ $id }}ExpiredCallback = function () {
|
||||
window.turnstile.reset();
|
||||
}
|
||||
|
||||
@this.watch("{{ $model }}", (value, old) => {
|
||||
// If there was a value, and now there isn't, reset the Turnstile.
|
||||
if (!!old && !value) {
|
||||
window.turnstile.reset();
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
Reference in New Issue
Block a user