/**
  * Validate the captcha value from the request and output an error if not valid
  *
  * @param mixed $value
  * @return bool
  */
 public function isValid($value)
 {
     $validCaptcha = true;
     if ($this->captcha !== null) {
         $status = $this->captcha->validateReCaptcha();
         if ($status == false || $status['error'] !== '') {
             $validCaptcha = false;
             $this->addError($status['error'], 1447258047591);
         }
     }
     return $validCaptcha;
 }
Exemplo n.º 2
0
 /**
  * Rendering the output of the captcha
  *
  * @return string
  */
 public function render()
 {
     if ($this->captcha !== null) {
         $output = $this->captcha->getReCaptcha();
         $status = $this->captcha->validateReCaptcha();
         if ($status == false || $status['error'] !== '') {
             $output .= '<strong class="error">' . \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_recaptcha_' . $status['error'], 'Recaptcha') . '</strong>';
         }
     } else {
         $output = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_captcha.notinstalled', 'Recaptcha', ['recaptcha']);
     }
     return $output;
 }
Exemplo n.º 3
0
 /**
  * Validate the captcha value from the request and output an error if not valid
  *
  * @param string $value
  *
  * @return bool
  */
 public function isValid($value)
 {
     $validCaptcha = true;
     $captchaWasValidPreviously = $this->session->get('captchaWasValidPreviously');
     if ($this->captcha !== null && $captchaWasValidPreviously !== true) {
         $status = $this->captcha->validateReCaptcha();
         if ($status == false || $status['error'] !== '') {
             $validCaptcha = false;
             $this->addError(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('error_recaptcha_' . $status['error'], 'Recaptcha'), 1307421960);
         }
     }
     $this->session->set('captchaWasValidPreviously', $validCaptcha);
     return $validCaptcha;
 }
 /**
  * Rendering the output of the captcha
  *
  * @return string
  */
 public function render()
 {
     if ($this->captcha !== null) {
         $output = $this->captcha->getReCaptcha();
         /** @var \TYPO3\CMS\Form\Validation\RecaptchaValidator $recaptchaValidator */
         $recaptchaValidator = GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Validation\\RecaptchaValidator');
         $validationError = $recaptchaValidator->getError();
         if (count($validationError)) {
             /** @var ContentObjectRenderer $content */
             $content = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
             $output .= '<strong class="error">' . $content->cObjGetSingle($validationError['cObj'], $validationError['cObj.']) . '</strong>';
         }
     } else {
         $output = LocalizationUtility::translate('error_captcha.notinstalled', 'Recaptcha', ['recaptcha']);
     }
     return $output;
 }