Files
newznab-tmux/app/Rules/TurnstileRule.php
T
2025-10-27 13:42:04 +01:00

27 lines
581 B
PHP

<?php
namespace App\Rules;
use App\Services\TurnstileService;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class TurnstileRule implements ValidationRule
{
/**
* Run the validation rule.
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (empty($value)) {
$fail('Please complete the captcha verification.');
return;
}
if (! TurnstileService::verify($value)) {
$fail('The captcha verification failed. Please try again.');
}
}
}