[TASK] add captcha validator
This commit is contained in:
parent
6f1383ce50
commit
74f9767cf4
@ -27,6 +27,7 @@ use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder;
|
|||||||
use TYPO3\CMS\Extbase\Service\EnvironmentService;
|
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;
|
||||||
|
|
||||||
class ActionController extends BaseController
|
class ActionController extends BaseController
|
||||||
{
|
{
|
||||||
@ -835,4 +836,26 @@ class ActionController extends BaseController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/** **/
|
||||||
|
protected function valideCaptcha($captchaId, $value
|
||||||
|
) {
|
||||||
|
$cacheIdentifier = $GLOBALS['TSFE']->fe_user->getKey('ses', $captchaId);
|
||||||
|
|
||||||
|
if (!$cacheIdentifier) {
|
||||||
|
$this->addValidationError(
|
||||||
|
'captcha',
|
||||||
|
'validator.notvalid'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// get captcha secret from cache and compare
|
||||||
|
$cache = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('bwcaptcha');
|
||||||
|
$phrase = $cache->get($cacheIdentifier);
|
||||||
|
if ($phrase && $phrase === $value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$this->addValidationError(
|
||||||
|
'captcha',
|
||||||
|
'validator.notvalid'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user