mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
31 lines
695 B
PHP
31 lines
695 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Services\RecaptchaService;
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class RecaptchaRule implements ValidationRule
|
|
{
|
|
/**
|
|
* Validate the reCAPTCHA response token.
|
|
*
|
|
* @param Closure(string): void $fail
|
|
*/
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
if (! is_string($value) || $value === '') {
|
|
$fail('Please complete the captcha verification.');
|
|
|
|
return;
|
|
}
|
|
|
|
if (! RecaptchaService::verify($value)) {
|
|
$fail('The captcha verification failed. Please try again.');
|
|
}
|
|
}
|
|
}
|