<?php
declare(strict_types=1);
namespace Smakmedia\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class IndexController extends AbstractController
{
/**
* @Route("/", name="dashboard")
*/
public function index(AuthenticationUtils $authenticationUtils): Response
{
if (!($this->isGranted('ROLE_USER'))) {
return $this->redirectToRoute('login');
}
$error = $authenticationUtils->getLastAuthenticationError();
$username = $authenticationUtils->getLastUsername();
return $this->render('index.html.twig', [
'username' => $username,
'error' => $error,
]);
}
}