first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

29
app/Rules/Recaptcha.php Normal file
View File

@@ -0,0 +1,29 @@
<?php
namespace App\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Support\Facades\Http;
class Recaptcha implements ValidationRule
{
/**
* Run the validation rule.
*
* @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$gResponseToken = (string) $value;
$response = Http::asForm()->post(
'https://www.google.com/recaptcha/api/siteverify',
['secret' => setting('recaptcha_secret_key'), 'response' => $gResponseToken]
);
if (!json_decode($response->body(), true)['success']) {
$fail('Invalid recaptcha');
}
}
}