femanager
femanager copied to clipboard
Captcha validation always wrong
I wanted to implement sr_freecap with femanager, but the captcha validation always fails. Maybe this error doesn't just occur in my project, so here is a solution I found.
TYPO3 setup:
- TYPO3 v12.4
- femanager v8
- sr-freecap v12.4
In femanager/Classes/Domain/ValidatorCaptchaValidator.php is a function called validCaptcha. That function tries to access the captcha value given by the user.
It wants to read from $this->pluginVariables['captcha'], but that value doesn't exist. The value is located at $this->pluginVariables['tx_femanager_registration']['captcha'].
Here is the updated function that works for me:
protected function validCaptcha(): bool
{
$isValid = false;
$wordRepository = GeneralUtility::makeInstance(WordRepository::class);
$wordObject = $wordRepository->getWord();
$wordHash = $wordObject->getWordHash();
if (!empty($wordHash) && !empty($this->pluginVariables['tx_femanager_registration']['captcha'])) {
if ($wordObject->getHashFunction() == 'md5') {
if (
md5(
strtolower(
mb_convert_encoding(
(string) $this->pluginVariables['tx_femanager_registration']['captcha'],
'ISO-8859-1'
)
)
) == $wordHash
) {
$wordRepository->cleanUpWord();
$isValid = true;
}
}
}
return $isValid;
}