Add all files
This commit is contained in:
23
themes/default/views/components/captcha/hcaptcha.blade.php
Normal file
23
themes/default/views/components/captcha/hcaptcha.blade.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<script src="https://js.hcaptcha.com/1/api.js?render=explicit&onload=captchaOnload" async defer></script>
|
||||
<div id="h-captcha" data-sitekey="{{ config('settings.captcha_site_key') }}"></div>
|
||||
|
||||
<script>
|
||||
function captchaOnload() {
|
||||
// On livewire validation error reset captcha
|
||||
Livewire.hook('request', ({
|
||||
succeed,
|
||||
fail
|
||||
}) => {
|
||||
succeed(() => {
|
||||
hcaptcha.reset();
|
||||
});
|
||||
})
|
||||
|
||||
hcaptcha.render('h-captcha', {
|
||||
sitekey: '{{ config('settings.captcha_site_key') }}',
|
||||
callback: function(token) {
|
||||
@this.set('captcha', token, false)
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
18
themes/default/views/components/captcha/index.blade.php
Normal file
18
themes/default/views/components/captcha/index.blade.php
Normal file
@@ -0,0 +1,18 @@
|
||||
@if (config('settings.captcha') !== 'disabled')
|
||||
<div class="flex flex-col justify-center mt-2">
|
||||
<div wire:ignore>
|
||||
@if (config('settings.captcha') == 'recaptcha-v2')
|
||||
<x-captcha.recaptcha-v2 :$form />
|
||||
@elseif(config('settings.captcha') == 'recaptcha-v3')
|
||||
<x-captcha.recaptcha-v3 :$form />
|
||||
@elseif(config('settings.captcha') == 'turnstile')
|
||||
<x-captcha.turnstile :$form />
|
||||
@elseif(config('settings.captcha') == 'hcaptcha')
|
||||
<x-captcha.hcaptcha :$form />
|
||||
@endif
|
||||
</div>
|
||||
@error('captcha')
|
||||
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
@endif
|
||||
@@ -0,0 +1,21 @@
|
||||
<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=captchaOnload" async defer></script>
|
||||
<div id="g-recaptcha" data-sitekey="{{ config('settings.captcha_site_key') }}"></div>
|
||||
|
||||
<script>
|
||||
function captchaOnload() {
|
||||
// On livewire validation error reset captcha
|
||||
Livewire.hook('request', ({
|
||||
succeed,
|
||||
fail
|
||||
}) => {
|
||||
succeed(() => grecaptcha.reset());
|
||||
})
|
||||
|
||||
grecaptcha.render('g-recaptcha', {
|
||||
sitekey: '{{ config('settings.captcha_site_key') }}',
|
||||
callback: function(token) {
|
||||
@this.set('captcha', token, false)
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script src="https://www.google.com/recaptcha/api.js?render={{ config('settings.captcha_site_key') }}" async defer>
|
||||
</script>
|
||||
<div id="g-recaptcha" data-sitekey="{{ config('settings.captcha_site_key') }}"></div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
const submitBtn = document.querySelector('#{{ $form }} button[type="submit"]')
|
||||
|
||||
submitBtn.addEventListener("click", function(event) {
|
||||
event.preventDefault();
|
||||
grecaptcha.ready(function() {
|
||||
grecaptcha.execute('{{ config('settings.captcha_site_key') }}', {
|
||||
action: 'submit'
|
||||
}).then(function(token) {
|
||||
@this.set('captcha', token, false)
|
||||
@this.submit();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
34
themes/default/views/components/captcha/turnstile.blade.php
Normal file
34
themes/default/views/components/captcha/turnstile.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
@assets
|
||||
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"></script>
|
||||
@endassets
|
||||
|
||||
<div id="cf-turnstile"></div>
|
||||
|
||||
<script>
|
||||
function renderTurnstile() {
|
||||
const isDarkMode = localStorage.getItem('_x_darkMode') === 'true';
|
||||
const theme = isDarkMode ? 'dark' : 'light';
|
||||
|
||||
turnstile.render('#cf-turnstile', {
|
||||
sitekey: '{{ config('settings.captcha_site_key') }}',
|
||||
size: 'flexible',
|
||||
theme: theme,
|
||||
callback: token => @this.set('captcha', token, false),
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('livewire:initialized', () => {
|
||||
// On livewire validation error reset captcha
|
||||
Livewire.hook('request', ({ succeed }) => {
|
||||
succeed(() => {
|
||||
turnstile.reset();
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
@script
|
||||
<script>
|
||||
renderTurnstile();
|
||||
</script>
|
||||
@endscript
|
||||
Reference in New Issue
Block a user