src/Controller/IndexController.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Smakmedia\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  8. class IndexController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/", name="dashboard")
  12.      */
  13.     public function index(AuthenticationUtils $authenticationUtils): Response
  14.     {
  15.         if (!($this->isGranted('ROLE_USER'))) {
  16.             return $this->redirectToRoute('login');
  17.         }
  18.         $error $authenticationUtils->getLastAuthenticationError();
  19.         $username $authenticationUtils->getLastUsername();
  20.         return $this->render('index.html.twig', [
  21.             'username' => $username,
  22.             'error' => $error,
  23.         ]);
  24.     }
  25. }