Skip to content

Commit 0be42e1

Browse files
feat:[lar-128] Add recaptcha on user register
1 parent 8e33403 commit 0be42e1

File tree

5 files changed

+85
-8
lines changed

5 files changed

+85
-8
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,6 @@ TWITTER_CONSUMER_KEY=your-consumer-key
8282
TWITTER_CONSUMER_SECRET=your-consumer-secret
8383
TWITTER_ACCESS_TOKEN=your-accesss_token
8484
TWITTER_ACCESS_SECRET=your-access-token-secret
85+
86+
GOOGLE_RECAPTCHA_SITE_KEY=your-recaptcha-site-key
87+
GOOGLE_RECAPTCHA_SECRET_KEY=your-secret-key

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"blade-ui-kit/blade-heroicons": "^2.4",
1414
"cyrildewit/eloquent-viewable": "^7.0",
1515
"doctrine/dbal": "^3.6.4",
16+
"dutchcodingcompany/livewire-recaptcha": "^1.0",
1617
"filament/filament": "^3.2",
1718
"filament/notifications": "^3.2",
1819
"filament/spatie-laravel-media-library-plugin": "^3.2",

composer.lock

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/services.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,13 @@
6161
'channel' => env('TELEGRAM_CHANNEL'),
6262
],
6363

64+
'google' => [
65+
'recaptcha' => [
66+
'site_key' => env('GOOGLE_RECAPTCHA_SITE_KEY'),
67+
'secret_key' => env('GOOGLE_RECAPTCHA_SECRET_KEY'),
68+
'version' => 'v3',
69+
'score' => 0.5,
70+
],
71+
],
72+
6473
];

resources/views/livewire/pages/auth/register.blade.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?php
22
33
use App\Models\User;
4+
use DutchCodingCompany\LivewireRecaptcha\ValidatesRecaptcha;
45
use Illuminate\Auth\Events\Registered;
56
use Illuminate\Support\Facades\Hash;
67
use Livewire\Volt\Component;
78
use Illuminate\Validation\Rules\Password;
89
9-
new class extends Component
10-
{
10+
new class extends Component {
1111
public string $name = '';
1212
public string $email = '';
1313
public string $username = '';
1414
public string $password = '';
15+
public string $gRecaptchaResponse;
1516
17+
#[ValidatesRecaptcha]
1618
public function register(): void
1719
{
1820
$validated = $this->validate([
@@ -85,14 +87,18 @@ public function register(): void
8587
</dl>
8688

8789
<div class="mt-16 relative text-sm space-y-4 max-w-lg mx-auto">
88-
<svg class="absolute left-0 top-0 size-7 -translate-x-8 -translate-y-2 rotate-12 transform text-green-600" fill="currentColor" viewBox="0 0 32 32" aria-hidden="true">
89-
<path d="M9.352 4C4.456 7.456 1 13.12 1 19.36c0 5.088 3.072 8.064 6.624 8.064 3.36 0 5.856-2.688 5.856-5.856 0-3.168-2.208-5.472-5.088-5.472-.576 0-1.344.096-1.536.192.48-3.264 3.552-7.104 6.624-9.024L9.352 4zm16.512 0c-4.8 3.456-8.256 9.12-8.256 15.36 0 5.088 3.072 8.064 6.624 8.064 3.264 0 5.856-2.688 5.856-5.856 0-3.168-2.304-5.472-5.184-5.472-.576 0-1.248.096-1.44.192.48-3.264 3.456-7.104 6.528-9.024L25.864 4z" />
90+
<svg
91+
class="absolute left-0 top-0 size-7 -translate-x-8 -translate-y-2 rotate-12 transform text-green-600"
92+
fill="currentColor" viewBox="0 0 32 32" aria-hidden="true">
93+
<path
94+
d="M9.352 4C4.456 7.456 1 13.12 1 19.36c0 5.088 3.072 8.064 6.624 8.064 3.36 0 5.856-2.688 5.856-5.856 0-3.168-2.208-5.472-5.088-5.472-.576 0-1.344.096-1.536.192.48-3.264 3.552-7.104 6.624-9.024L9.352 4zm16.512 0c-4.8 3.456-8.256 9.12-8.256 15.36 0 5.088 3.072 8.064 6.624 8.064 3.264 0 5.856-2.688 5.856-5.856 0-3.168-2.304-5.472-5.184-5.472-.576 0-1.248.096-1.44.192.48-3.264 3.456-7.104 6.528-9.024L25.864 4z" />
9095
</svg>
9196
<p class="relative text-gray-600 dark:text-gray-400">
9297
{{ __('pages/auth.register.advantages.quote') }}
9398
</p>
9499
<p class="mt-2 text-gray-900 dark:text-white">
95-
<span class="italic text-gray-400 dark:text-gray-500">"The Pragmatic Programmer"</span> {{ __('pages/auth.register.advantages.quote_authors') }}
100+
<span
101+
class="italic text-gray-400 dark:text-gray-500">"The Pragmatic Programmer"</span> {{ __('pages/auth.register.advantages.quote_authors') }}
96102
</p>
97103
</div>
98104
</div>
@@ -114,7 +120,7 @@ public function register(): void
114120

115121
<x-validation-errors />
116122

117-
<form wire:submit="register" class="space-y-6">
123+
<form wire:submit="register" wire:recaptcha class="space-y-6">
118124
<div class="space-y-3">
119125
<x-filament::input.wrapper>
120126
<x-filament::input
@@ -167,12 +173,14 @@ public function register(): void
167173
<div>
168174
<x-buttons.primary type="submit" class="group w-full relative">
169175
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
170-
<x-untitledui-lock class="size-5 text-green-500 group-hover:text-green-600" aria-hidden="true" />
176+
<x-untitledui-lock class="size-5 text-green-500 group-hover:text-green-600"
177+
aria-hidden="true" />
171178
</span>
172179
{{ __('pages/auth.register.submit') }}
173180
</x-buttons.primary>
174181
</div>
175182
</form>
183+
@livewireRecaptcha
176184
</div>
177185

178186
@include('partials._socials-link')

0 commit comments

Comments
 (0)