Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

crispy_lorenzo's avatar

Can't log in using Jetstream with Google recaptcha

Hi, I tried to add the google recaptcha using biscolab's library into the login page made with Jetstream. Firstly on the FortifyServiceProvider.php I modified the boot method adding this function:

Fortify::authenticateUsing(function (Request $request) {
                $user = User::where('name', $request->name)->first();

                if ($user && Hash::check($request->password, $user->password)) {
                    return $user;
                }
        });

Then for google recaptcha v2 integration I've added this code:

Fortify::authenticateUsing(function (Request $request) {
            $validator = Validator::make($request->all(), [
                "name" => "required",
                "password" => "required",
                recaptchaFieldName() => recaptchaRuleName()
            ]);

            if(!($validator->fails()))
            {
                $user = User::where('name', $request->name)->first();

                if ($user && Hash::check($request->password, $user->password)) {
                    return $user;
                }
            }

        });

Now the problem: even if all the conditions are validated and the user is returned, the login page send me back with an error saying "These credentials do not match our records.". If I remove the recaptcha validation, then the user is returned in the same way as before but now I'm logged in.

0 likes
2 replies

Please or to participate in this conversation.