/**
  * Register valid_captcha validation rule.
  *
  * @return void
  */
 public function registerValidCaptchaValidationRule()
 {
     // registering valid_captcha rule
     Validator::extend('valid_captcha', function ($attribute, $value, $parameters, $validator) {
         $captchaId = find_captcha_id_in_form_data($validator->getData());
         $captcha = captcha_instance($captchaId);
         return $captcha->Validate($value);
     });
     // registering custom error message
     Validator::replacer('valid_captcha', function ($message, $attribute, $rule, $parameters) {
         if ('validation.valid_captcha' === $message) {
             $message = 'CAPTCHA validation failed, please try again.';
         }
         return $message;
     });
 }
Example #2
0
 /**
  * Reset captcha for current instance.
  *
  * @param string  $captchaId
  * @return void
  */
 function captcha_reset($captchaId = '')
 {
     if (empty($captchaId) && \Request::isMethod('get')) {
         $errorMessages = 'The "captcha_reset" helper function requires you to pass the configuration option key defined in config/captcha.php file on HTTP GET request. ';
         $errorMessages .= 'For example: captcha_reset(\'LoginCaptcha\');';
         throw new InvalidArgumentException($errorMessages);
     }
     if (empty($captchaId) && \Request::isMethod('post')) {
         $captchaId = find_captcha_id_in_form_data(\Request::all());
     }
     $captcha = captcha_instance($captchaId);
     return $captcha->Reset();
 }
Example #3
0
 /**
  * Reset captcha for current instance.
  *
  * @return void
  */
 function captcha_reset()
 {
     $captcha =& captcha_instance();
     return $captcha->Reset();
 }