mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 14:36:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			640 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			640 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Extensions\Captcha\Schemas\Turnstile;
 | |
| 
 | |
| use App\Extensions\Captcha\CaptchaService;
 | |
| use Closure;
 | |
| use Exception;
 | |
| use Illuminate\Contracts\Validation\ValidationRule;
 | |
| use Illuminate\Support\Facades\App;
 | |
| 
 | |
| class Rule implements ValidationRule
 | |
| {
 | |
|     public function validate(string $attribute, mixed $value, Closure $fail): void
 | |
|     {
 | |
|         try {
 | |
|             App::call(fn (CaptchaService $service) => $service->get('turnstile')->validateResponse($value));
 | |
|         } catch (Exception $exception) {
 | |
|             report($exception);
 | |
| 
 | |
|             $fail('Captcha validation failed: ' . $exception->getMessage());
 | |
|         }
 | |
|     }
 | |
| }
 | 
