File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525use TYPO3 \CMS \Backend \Utility \BackendUtility as BackendUtilityCore ;
2626use TYPO3 \CMS \Core \Database \ConnectionPool ;
2727use TYPO3 \CMS \Core \Http \ApplicationType ;
28+ use TYPO3 \CMS \Core \Http \PropagateResponseException ;
2829use TYPO3 \CMS \Core \Http \RedirectResponse ;
2930use TYPO3 \CMS \Core \Http \UploadedFile ;
3031use \TYPO3 \CMS \Core \Resource \Enum \DuplicationBehavior ;
@@ -655,4 +656,25 @@ public function sendCreateUserConfirmationMailFromBackend(User $user): void
655656 $ this ->request
656657 );
657658 }
659+
660+ protected function validateMissingCaptcha (string $ redirectAction ): void
661+ {
662+ if ($ this ->isCaptchaEnabled () && $ this ->request ->getAttribute ('extbase ' )->getArgument ('captcha ' ) === '' ) {
663+ $ this ->addFlashMessage (
664+ LocalizationUtility::translate ('validationErrorCaptcha ' ),
665+ '' ,
666+ ContextualFeedbackSeverity::ERROR
667+ );
668+ throw new PropagateResponseException ($ this ->redirect ($ redirectAction ), 12398019239 );
669+ }
670+ }
671+
672+ protected function isCaptchaEnabled (): bool {
673+ $ extbaseAttribute = $ this ->request ->getAttribute ('extbase ' );
674+ $ controllerName = strtolower ($ extbaseAttribute ->getControllerName ());
675+
676+ return $ extbaseAttribute ->hasArgument ('captcha ' ) &&
677+ $ this ->config [$ controllerName . '. ' ]['validation. ' ]['captcha. ' ]['captcha ' ] == true &&
678+ ExtensionManagementUtility::isLoaded ('sr_freecap ' );
679+ }
658680}
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ public function editAction(): ResponseInterface
5454 #[Validate(['validator ' => CaptchaValidator::class, 'param ' => 'captcha ' ])]
5555 public function updateAction (User $ user , ?string $ captcha = null )
5656 {
57+ $ this ->validateMissingCaptcha ('edit ' );
58+
5759 $ currentUser = UserUtility::getCurrentUser ();
5860 $ userValues = $ this ->request ->getArgument ('user ' ) ?? [];
5961 $ token = $ this ->request ->getArgument ('token ' ) ?? null ;
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ public function newAction(): ResponseInterface
5959 #[Validate(['validator ' => CaptchaValidator::class, 'param ' => 'captcha ' ])]
6060 public function createAction (User $ user , ?string $ captcha = null ): ResponseInterface
6161 {
62+ $ this ->validateMissingCaptcha ('new ' );
63+
6264 if ($ this ->ratelimiterService ->isLimited ()) {
6365 $ this ->addFlashMessage (
6466 LocalizationUtility::translate ('ratelimiter_too_many_attempts ' ),
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ public function newAction(): ResponseInterface
6666 #[Validate(['validator ' => CaptchaValidator::class, 'param ' => 'captcha ' ])]
6767 public function createAction (User $ user , ?string $ captcha = null ): ResponseInterface
6868 {
69+ $ this ->validateMissingCaptcha ('new ' );
70+
6971 if ($ this ->ratelimiterService ->isLimited ()) {
7072 $ this ->addFlashMessage (
7173 LocalizationUtility::translate ('ratelimiter_too_many_attempts ' ),
Original file line number Diff line number Diff line change @@ -272,6 +272,7 @@ public function validateField(string $pluginName = 'tx_femanager_new'): bool
272272 $ wordRepository = GeneralUtility::makeInstance (
273273 WordRepository::class
274274 );
275+ $ wordRepository ->setRequest ($ this ->request ?? $ GLOBALS ["TYPO3_REQUEST " ]);
275276 $ wordObject = $ wordRepository ->getWord ();
276277 $ wordHash = $ wordObject ->getWordHash ();
277278 $ userVal = md5 (strtolower (mb_convert_encoding ($ this ->getValue (), 'ISO-8859-1 ' )));
You can’t perform that action at this time.
0 commit comments