/** * Redirect user to Google Captcha challenge * * @param \Zend_Gdata_App_CaptchaRequiredException $e * @return void */ protected function _redirectToCaptcha($e) { $redirectUrl = $this->getUrl('*/*/index', ['store' => $this->_getStore()->getId(), 'captcha_token' => $this->urlEncoder->encode($e->getCaptchaToken()), 'captcha_url' => $this->urlEncoder->encode($e->getCaptchaUrl())]); if ($this->getRequest()->isAjax()) { $this->getResponse()->representJson($this->_objectManager->get('Magento\\Core\\Helper\\Data')->jsonEncode(['redirect' => $redirectUrl])); } else { $this->_redirect($redirectUrl); } }
/** * Redirect user to Google Captcha challenge * * @param \Zend_Gdata_App_CaptchaRequiredException $e * @return \Magento\Framework\Controller\ResultInterface */ protected function _redirectToCaptcha($e) { $redirectUrl = $this->getUrl('*/*/index', ['store' => $this->_getStore()->getId(), 'captcha_token' => $this->urlEncoder->encode($e->getCaptchaToken()), 'captcha_url' => $this->urlEncoder->encode($e->getCaptchaUrl())]); if ($this->getRequest()->isAjax()) { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); return $resultJson->setData(['redirect' => $redirectUrl]); } else { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); return $resultRedirect->setUrl($redirectUrl); } }
/** * Redirect user to Google Captcha challenge * * @param Zend_Gdata_App_CaptchaRequiredException $e */ protected function _redirectToCaptcha($e) { $this->_redirect('*/*/index', array('store' => $this->_getStore()->getId(), 'captcha_token' => Mage::helper('core')->urlEncode($e->getCaptchaToken()), 'captcha_url' => Mage::helper('core')->urlEncode($e->getCaptchaUrl()))); }
/** * Redirect user to Google Captcha challenge * * @param Zend_Gdata_App_CaptchaRequiredException $e */ protected function _redirectToCaptcha($e) { $redirectUrl = $this->getUrl('*/*/index', array('store' => $this->_getStore()->getId(), 'captcha_token' => Mage::helper('core')->urlEncode($e->getCaptchaToken()), 'captcha_url' => Mage::helper('core')->urlEncode($e->getCaptchaUrl()))); if ($this->getRequest()->isAjax()) { $this->getResponse()->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode(array('redirect' => $redirectUrl))); } else { $this->_redirect($redirectUrl); } }
/** * Prints CAPTCHA verfication form * @param Zend_Gdata_App_CaptchaRequiredException $e * @return string $html HTML string */ public static function printCaptchaError(Zend_Gdata_App_CaptchaRequiredException $e) { $obj = strpos($_SERVER['HTTP_REFERER'], 'options-general.php') === FALSE ? 'GDocs' : 'GDocsOptions'; return "Google requested CAPTCHA verification.<br/>\n\t\t<img src='" . $e->getCaptchaUrl() . "' style='margin:5px 0 4px' />\n\t\t<form method='post' action='options.php' onsubmit='javascript: {$obj}.verify (this); return false;'>\n\t\t\t<input type='hidden' name='gdocs_token' id='gdocs_token' value='" . $e->getCaptchaToken() . "' />\n\t\t\t<input type='text' name='gdocs_captcha' size='40' id='gdocs_captcha' />\n\t\t\t<input type='submit' value='Submit' onclick='javascript: {$obj}.verify (this); return false;' />\n\t\t</form>"; }