Triumfator's avatar

Jetstream Registration and Google Recaptcha V3

Has anyone successfully integrated Recaptcha V3 into Jetstream registration form?

Did you put recaptcha validation logic in App\Actions\Fortify\CreateNewUser.php?

Just wandering what the best approach is...

0 likes
4 replies
Triumfator's avatar

Small update for anyone who is researching this topic....

I accomplished this implementation, and recaptcha validation logic was used in App\Actions\Fortify\CreateNewUser.php. Guzzlehttp was used for dealing with google info. No other packages were used.

xetic's avatar

Breeze: https://github.com/LaravelDaily/laravel-recaptcha/commit/ff7e46398217b331ae8ae3b23a55a84bf6bcdfe4

There may be one difference though depending on your set. Instead of adding validation to app/Http/Controllers/Auth/RegisteredUserController.php I had to add it to app/Actions/Fortify/CreateNewUser.php:

    {
        Validator::make($input, [
            'first_name' => ['required', 'string', 'max:180'],
            'last_name' => ['required', 'string', 'max:180'],
            'email' => ['required', 'string', 'email', 'max:180', 'unique:users'],
            'password' => $this->passwordRules(),
            'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
            'recaptcha_token' => ['required', new Recaptcha($input['recaptcha_token'])],
        ])->validate();

Here's an implementation video: https://www.youtube.com/watch?v=F5V8908k7rU

Please or to participate in this conversation.