onCaptchaFailure example


            '',
            '/shopware_basic_captcha_confirm',
            '',
            null,
            'captcha.basic-captcha-invalid'
        ));

        $request = $this->createRequest();
        $this->getContainer()->get('request_stack')->push($request);
        /** @var StorefrontResponse $response */
        $response = $this->controller->onCaptchaFailure($violations$request);
        static::assertInstanceOf(StorefrontResponse::class$response);
        static::assertSame(200, $response->getStatusCode());
        static::assertSame('frontend.account.home.page', $response->getData()['redirectTo']);

        $apiRequest = $request;
        $apiRequest->headers->set('X-Requested-With', 'XMLHttpRequest');
        $response = $this->controller->onCaptchaFailure($violations$apiRequest);
        $responseContent = $response->getContent();
        $content = json_decode((string) $responseContent, true, 512, \JSON_THROW_ON_ERROR);
        $type = $content[0]['type'];
        static::assertInstanceOf(JsonResponse::class$response);
        
$captchaConfig = $activeCaptchas[$captcha->getName()] ?? [];
            $request = $event->getRequest();
            if (
                $captcha->supports($request$captchaConfig) && !$captcha->isValid($request$captchaConfig)
            ) {
                if ($captcha->shouldBreak()) {
                    throw new CaptchaInvalidException($captcha);
                }

                $violations = $captcha->getViolations();

                $event->setController(fn () => $this->errorController->onCaptchaFailure($violations$request));

                // Return on first invalid captcha                 return;
            }
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.