mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 09:18:54 +00:00
27 lines
581 B
PHP
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.');
|
|
}
|
|
}
|
|
}
|