• Reading time ~ 1 min
  • 02.02.2023

The Google reCaptcha Enterprise for Laravel is a package that provides easy configuration of reCaptcha and a handy validation rule to verify your user token scores.

Here's an example of how you can use this package to validate the user's Recaptcha score using the provided validation Rule class:

use Illuminate\Foundation\Http\FormRequest;
use Oneduo\RecaptchaEnterprise\Rules\Recaptcha;

class TestRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'g-recaptcha-response' => [
                'required',
                new Recaptcha()
            ],
        ];
    }
    public function authorize(): bool
    {
        return true;
    }
}

When validating a reCaptcha token, you need to configure a score threshold acceptable for considering the user as valid. You can customize your app's score based on reCaptcha data using the provided configuration option in this package:

// config/recaptcha-enterprise.php
return [
    'score_threshold' => 0.7,
    // ...
];

You can get started with this package on GitHub at oneduo/laravel-recaptcha-enterprise and install it via composer:

composer require oneduo/laravel-recaptcha-enterprise

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297