tutorials / recaptcha3
There is no license information available for the latest version (1.0.2) of this package.
Google recaptcha v3 integration for laravel/inertia
1.0.2
2024-01-21 13:09 UTC
Requires
- php: ^8.1
This package is not auto-updated.
Last update: 2024-10-28 15:22:11 UTC
README
- Install composer package
composer require tutorials/recaptcha3
- Define service provider in
config/app.php
'providers' => [ ... Tutorials\Recaptcha3\RecaptchaServiceProvider::class ],
- Define variables in
.env
file and put values from recaptcha admin panel
RECAPTCHA_ENABLED=
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
- Put
recaptcha
middleware on route
Route::post('/login', LoginController::class)->middleware('recaptcha'); Route::post('/register', LoginController::class)->middleware('recaptcha:0.6');
- Insert
@recaptcha
blade directive in the layout
<!DOCTYPE html> <html lang="en"> <head> <title>Recaptcha</title> @recaptcha </head> </html>
- Wrap your form submit logic with recaptcha validation
window.recaptcha('action_name_for_recaptcha_statistic').then((token) => { // form submition logic form.transform((data) => ({ ...data, recaptcha_token: token, // recaptcha_token is required })).post(route('login')) });
- Run
php artisan view:clear
to clear the view cache