/** * Generates an auth code for accessing a form that is independent from * any table records but only needs an identifier and a context name for that * identifier. * * The identifier should be unique in the given context. * * @param $identifier * @param $context * @param null $additionalData * @return string * @deprecated Since 0.7.0, will be removed in version 1.0.0, use AuthCodeRecordRepository instead. * @see \Tx\Authcode\Domain\Repository\AuthCodeRepository::generateIndependentAuthCode() */ public function generateTableIndependentAuthCode($identifier, $context, $additionalData = NULL) { $authCode = $this->createAuthCode(); if (isset($additionalData)) { $authCode->setAdditionalData($additionalData); } $this->authCodeRepository->generateIndependentAuthCode($authCode, $identifier, $context); return $authCode->getAuthCode(); }
/** * Generates an auth code that is independent from a database record. * * @throws MissingSettingException */ protected function generateRecordIndependentAuthCode() { $identifier = ''; $context = ''; if ($this->settings['identifier']) { $identifier = trim($this->utilityFuncs->getSingle($this->settings, 'identifier')); } if (empty($identifier)) { throw new MissingSettingException('identifier'); } if ($this->settings['context']) { $context = trim($this->utilityFuncs->getSingle($this->settings, 'context')); } if (empty($context)) { throw new MissingSettingException('context'); } /** @var \Tx\Authcode\Domain\Model\AuthCode $authCodeRecord */ $authCodeRecord = $this->objectManager->get('Tx\\Authcode\\Domain\\Model\\AuthCode'); $this->authCodeRepository->generateIndependentAuthCode($authCodeRecord, $identifier, $context); $authCode = $authCodeRecord->getAuthCode(); $this->gp['generated_authCode'] = $authCode; /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */ $cObj = $this->cObj; // Looking for the page, which should be used for the authCode Link: // first look for TS-setting 'authCodePage' // second look for redirect_page-setting // third use current page if (isset($this->settings['authCodePage'])) { $authCodePage = $this->utilityFuncs->getSingle($this->settings, 'authCodePage'); } else { $authCodePage = $this->utilityFuncs->pi_getFFvalue($cObj->data['pi_flexform'], 'redirect_page', 'sMISC'); } if (!$authCodePage) { $authCodePage = $GLOBALS['TSFE']->id; } // Create the parameter-array for the authCode Link $paramsArray = array('authCode' => $authCode); // If we have set a formValuesPrefix, add it to the parameter-array $formValuesPrefix = $this->globals->getFormValuesPrefix(); if (!empty($formValuesPrefix)) { $paramsArray = array($formValuesPrefix => $paramsArray); } // Create the link, using typolink function, use baseUrl if set, else use t3lib_div::getIndpEnv('TYPO3_SITE_URL') $url = $cObj->getTypoLink_URL($authCodePage, $paramsArray); $tmpArr = parse_url($url); if (empty($tmpArr['scheme'])) { $url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ltrim($url, '/'); } $this->gp['authCodeUrl'] = $url; }