Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Captcha validation always wrong #538

Open
jonathanwede opened this issue Jan 17, 2024 · 0 comments
Open

Captcha validation always wrong #538

jonathanwede opened this issue Jan 17, 2024 · 0 comments

Comments

@jonathanwede
Copy link

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants