mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 18:44:46 +02:00

* refactor captcha * add default error message * prevent rule from being called multiple times * fixes * use config * Update this to latest * Remove this --------- Co-authored-by: Lance Pioch <git@lance.sh>
20 lines
518 B
PHP
20 lines
518 B
PHP
<?php
|
|
|
|
namespace App\Rules;
|
|
|
|
use App\Extensions\Captcha\Providers\CaptchaProvider;
|
|
use Closure;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
|
|
class ValidTurnstileCaptcha implements ValidationRule
|
|
{
|
|
public function validate(string $attribute, mixed $value, Closure $fail): void
|
|
{
|
|
$response = CaptchaProvider::get('turnstile')->validateResponse($value);
|
|
|
|
if (!$response['success']) {
|
|
$fail($response['message'] ?? 'Unknown error occurred, please try again');
|
|
}
|
|
}
|
|
}
|