when I want to check the score of the client inside if
statement I always get timeout-or-duplicate
error. but when I check the score outside of the if
statement it works fine.
this is the code when checking the score outside of the if
statement:
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" // appRulesRecaptcha.php:25
array:5 [▼ // appRulesRecaptcha.php:25
"success" => true
"challenge_ts" => "2024-12-26T19:58:05Z"
"hostname" => "localhost"
"score" => 0.9
"action" => "login"
]
*/
when I check the score inside of the if
statement:
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" // appRulesRecaptcha.php:29
array:2 [▼ // appRulesRecaptcha.php:29
"success" => false
"error-codes" => array:1 [▼
0 => "timeout-or-duplicate"
]
]
*/
1