mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 06:16:51 +01:00 
			
		
		
		
	 45db06a1bd
			
		
	
	
		45db06a1bd
		
			
		
	
	
	
	
		
			
			* 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');
 | |
|         }
 | |
|     }
 | |
| }
 |