direct_mail
direct_mail copied to clipboard
Keep access token when simulateUsergroup hook is called multiple times
Sometimes it can happen that the simulateUsergroup hook in the TypoScriptFrontendController is called multiple times for the same request. But as the validateAndRemoveAccessToken() method removes the registered access token after the first call, the second one will fail.
As a workaround i commented out the line where the token is removed after it has been successfully validated:
public static function validateAndRemoveAccessToken($accessToken)
{
/* @var \TYPO3\CMS\Core\Registry $registry */
$registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
$registeredAccessToken = $registry->get('tx_directmail', 'accessToken');
if (!empty($registeredAccessToken) && $registeredAccessToken === $accessToken) {
// $registry->remove('tx_directmail', 'accessToken'); <----
return true;
} else {
$registry->remove('tx_directmail', 'accessToken');
return false;
}
}
This works, but may be not the best solution.