Compare commits

..

No commits in common. "ca4052740cbd5bdf01e3f4937ab43daaf93a9843" and "f52f1c2c35b768d8c6376ec72cc5cc4fca772f58" have entirely different histories.

4 changed files with 30 additions and 28 deletions

View File

@ -28,7 +28,6 @@ use TYPO3\CMS\Extbase\Service\EnvironmentService;
use TYPO3\CMS\Extbase\Service\ExtensionService; use TYPO3\CMS\Extbase\Service\ExtensionService;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
use Blueways\BwCaptcha\Validation\Validator\CaptchaValidator; use Blueways\BwCaptcha\Validation\Validator\CaptchaValidator;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
class ActionController extends BaseController class ActionController extends BaseController
{ {
@ -840,40 +839,23 @@ class ActionController extends BaseController
/** **/ /** **/
protected function valideCaptcha($captchaId, $value protected function valideCaptcha($captchaId, $value
) { ) {
$captchaPhrases = $this->getFeUser()->getKey('ses', 'captchaPhrases'); $cacheIdentifier = $GLOBALS['TSFE']->fe_user->getKey('ses', $captchaId);
if (!$captchaPhrases || !is_array($captchaPhrases) || !is_string($value)) {
if (!$cacheIdentifier) {
$this->addValidationError( $this->addValidationError(
'captcha', 'captcha',
'validator.notvalid' 'validator.notvalid'
); );
} }
// get captcha secret from cache and compare // get captcha secret from cache and compare
$time = time(); $cache = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('bwcaptcha');
$captchaPhrases = array_filter( $phrase = $cache->get($cacheIdentifier);
$captchaPhrases, if ($phrase && $phrase === $value) {
function ($captchaLifetime) use ($time) { return true;
return $captchaLifetime > $time;
},
ARRAY_FILTER_USE_KEY
);
foreach ($captchaPhrases as $lifetime => $captchaPhrase) {
$isValid = !empty($captchaPhrase) && $captchaPhrase === $value;
if ($isValid) {
// remove solved captcha
unset($captchaPhrases[$lifetime]);
$this->getFeUser()->setKey('ses', 'captchaPhrases', $captchaPhrases);
$this->getFeUser()->storeSessionData();
return true;
}
} }
$this->addValidationError( $this->addValidationError(
'captcha', 'captcha',
'validator.notvalid' 'validator.notvalid'
); );
} }
protected function getFeUser(): FrontendUserAuthentication
{
return $GLOBALS['TSFE']->fe_user;
}
} }

View File

@ -45,7 +45,7 @@ class StringUtility
return $string; return $string;
} }
public static function getRandomString( function getRandomString(
int $length = 64, int $length = 64,
string $keyspace = null string $keyspace = null
): string { ): string {

View File

@ -30,7 +30,17 @@ return [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [ 'config' => [
'type' => 'language', 'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
]
],
'default' => 0,
], ],
], ],
'l10n_parent' => [ 'l10n_parent' => [

View File

@ -30,7 +30,17 @@ return [
'exclude' => true, 'exclude' => true,
'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
'config' => [ 'config' => [
'type' => 'language', 'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
]
],
'default' => 0,
], ],
], ],
'l10n_parent' => [ 'l10n_parent' => [