X-Git-Url: https://git.rapsys.eu/userbundle/blobdiff_plain/0811e272814cf05d6fc8bc76646a0be99bf79bb9..ee565ec6dec58e78f964eed1f449fdbd4b003f24:/Handler/AuthenticationFailureHandler.php diff --git a/Handler/AuthenticationFailureHandler.php b/Handler/AuthenticationFailureHandler.php index 7e7c132..6694043 100644 --- a/Handler/AuthenticationFailureHandler.php +++ b/Handler/AuthenticationFailureHandler.php @@ -46,6 +46,11 @@ use Symfony\Contracts\Translation\TranslatorInterface; * {@inheritdoc} */ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { + /** + * Alias string + */ + protected string $alias; + /** * Config array */ @@ -67,6 +72,7 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { * @param HttpUtils $httpUtils The http utils * @param array $options The options * @param LoggerInterface $logger The logger instance + * @param ?string $firewallName The firewall name * @param ContainerInterface $container The container instance * @param ManagerRegistry $doctrine The doctrine instance * @param MailerInterface $mailer The mailer instance @@ -75,12 +81,12 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { * @param RequestStack $stack The stack instance * @param TranslatorInterface $translator The translator instance */ - public function __construct(protected HttpKernelInterface $httpKernel, protected HttpUtils $httpUtils, protected array $options, protected ?LoggerInterface $logger, protected ContainerInterface $container, protected ManagerRegistry $doctrine, protected MailerInterface $mailer, protected RouterInterface $router, protected SluggerUtil $slugger, protected RequestStack $stack, protected TranslatorInterface $translator) { + public function __construct(protected HttpKernelInterface $httpKernel, protected HttpUtils $httpUtils, protected array $options, protected ?LoggerInterface $logger, private readonly ?string $firewallName, protected ContainerInterface $container, protected ManagerRegistry $doctrine, protected MailerInterface $mailer, protected RouterInterface $router, protected SluggerUtil $slugger, protected RequestStack $stack, protected TranslatorInterface $translator) { //Call parent constructor - parent::__construct($httpKernel, $httpUtils, $options, $logger); + parent::__construct($httpKernel, $httpUtils, $options, $logger, $firewallName); //Set config - $this->config = $container->getParameter(RapsysUserBundle::getAlias()); + $this->config = $container->getParameter($this->alias = RapsysUserBundle::getAlias()); } /** @@ -187,7 +193,7 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { //With not enabled user } elseif ($parent instanceof DisabledException) { //Add error message account is not enabled - $this->addFlash('error', $this->translator->trans('Account not enabled')); + $this->addFlash('error', $this->translator->trans('Account not enabled', [], $this->alias)); //Redirect on the same route with sent=1 to cleanup form return new RedirectResponse($this->router->generate($request->get('_route'), $request->get('_route_params')), 302); @@ -246,7 +252,7 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { } while(next($keys)); //Set translation - $current = $this->translator->trans($current); + $current = $this->translator->trans($current, [], $this->alias); //Remove reference unset($current); @@ -256,7 +262,8 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { $context['subject'] = $subject = ucfirst( $this->translator->trans( $this->config['register']['mail']['subject'], - $this->slugger->flatten($context, null, '.', '%', '%') + $this->slugger->flatten($context, null, '.', '%', '%'), + $this->alias ) ); @@ -285,14 +292,14 @@ class AuthenticationFailureHandler extends DefaultAuthenticationFailureHandler { //Catch obvious transport exception } catch(TransportExceptionInterface $e) { //Add error message mail unreachable - $this->addFlash('error', $this->translator->trans('Unable to reach account')); + $this->addFlash('error', $this->translator->trans('Unable to reach account', [], $this->alias)); } //Add notice - $this->addFlash('notice', $this->translator->trans('Your verification mail has been sent, to activate your account follow the confirmation link inside')); + $this->addFlash('notice', $this->translator->trans('Your verification mail has been sent, to activate your account follow the confirmation link inside', [], $this->alias)); //Add junk warning - $this->addFlash('warning', $this->translator->trans('If you did not receive a verification mail, check your Spam or Junk mail folder')); + $this->addFlash('warning', $this->translator->trans('If you did not receive a verification mail, check your Spam or Junk mail folder', [], $this->alias)); //Redirect on the same route with sent=1 to cleanup form return new RedirectResponse($this->router->generate($request->get('_route'), $request->get('_route_params')), 302);