src/Security/AuthenticationEntryPoint.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Security;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  7. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  8. use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
  9. class AuthenticationEntryPoint implements AuthenticationEntryPointInterface
  10. {
  11.     private $urlGenerator;
  12.     public function __construct(UrlGeneratorInterface $urlGenerator)
  13.     {
  14.         $this->urlGenerator $urlGenerator;
  15.     }
  16.     public function start(Request $requestAuthenticationException $authException null): RedirectResponse
  17.     {
  18.         $request->getSession()->getFlashBag()->add('danger''Musisz się zalogować, aby uzyskać dostęp do tej strony.');
  19.         return new RedirectResponse($this->urlGenerator->generate('app_login'));
  20.     }
  21. }