Google Recaptcha v3 funktioniert nicht richtig, wenn eine if-Anweisung verwendet wird (Laravel-Inertia)Php

PHP-Programmierer chatten hier
Guest
 Google Recaptcha v3 funktioniert nicht richtig, wenn eine if-Anweisung verwendet wird (Laravel-Inertia)

Post by Guest »

Wenn ich die Punktzahl des Clients in der if-Anweisung überprüfen möchte, erhalte ich immer die Fehlermeldung „Timeout-or-Duplicate“. aber wenn ich die Punktzahl außerhalb der if-Anweisung überprüfe, funktioniert es einwandfrei.
Dies ist der Code, wenn ich die Punktzahl außerhalb der if-Anweisung überprüfe:

Code: Select all

    public function validate(string $attribute, mixed $value, Closure $fail): void
{
$endpoint = config('services.google_recaptcha');

$response = Http::asForm()->post($endpoint['url'], [
'secret' => $endpoint['secret_key'],
'response' => $value,
])->json();

dd('outside of if statement', $response);

if(!($response['success'] and ($response['score'] > 0.5))) {

$fail('Something went wrong! please try again later.');

}
}

/*
"outside of if statement" // app\Rules\Recaptcha.php:25
array:5 [▼ // app\Rules\Recaptcha.php:25
"success" => true
"challenge_ts" => "2024-12-26T19:58:05Z"
"hostname" => "localhost"
"score" => 0.9
"action" => "login"
]
*/
wenn ich die Punktzahl innerhalb der if-Anweisung überprüfe:

Code: Select all

    public function validate(string $attribute, mixed $value, Closure $fail): void
{
$endpoint = config('services.google_recaptcha');

$response = Http::asForm()->post($endpoint['url'], [
'secret' => $endpoint['secret_key'],
'response' => $value,
])->json();

if(!($response['success'] and ($response['score'] > 0.5))) {

dd('inside of the if statement', $response);

$fail('Something went wrong! please try again later.');
}
}

/*
"inside of the if statement" // app\Rules\Recaptcha.php:29
array:2 [▼ // app\Rules\Recaptcha.php:29
"success" => false
"error-codes" => array:1 [▼
0 => "timeout-or-duplicate"
]
]
*/

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post