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"
]
*/
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"
]
]
*/