Réparation du DashboardController et AuthenticationController
This commit is contained in:
parent
8580911c1a
commit
a992c2ea6a
@ -3,27 +3,31 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
||||||
class AuthenticationController extends AbstractController
|
class AuthenticationController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route(path: '/login', name: 'app_login')]
|
#[Route(path: '/', name: 'app_login')]
|
||||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||||
{
|
{
|
||||||
// get the login error if there is one
|
if ($this->getUser()) {
|
||||||
|
return $this->redirectToRoute('dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
$error = $authenticationUtils->getLastAuthenticationError();
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
// last username entered by the user
|
|
||||||
$lastUsername = $authenticationUtils->getLastUsername();
|
$lastUsername = $authenticationUtils->getLastUsername();
|
||||||
|
|
||||||
return $this->render('authentication/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
|
return $this->render('login/index.html.twig', [
|
||||||
|
'last_username' => $lastUsername,
|
||||||
|
'error' => $error,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/logout', name: 'app_logout')]
|
#[Route(path: '/logout', name: 'app_logout')]
|
||||||
public function logout(): void
|
public function logout(): void
|
||||||
{
|
{
|
||||||
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
throw new \LogicException('Cette méthode est interceptée par Symfony pour déconnecter.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,18 +10,21 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class DashboardController extends AbstractController
|
class DashboardController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/', name: 'dashboard')]
|
#[Route('/', name: 'dashboard')]
|
||||||
|
#[Route('/admin', name: 'admin_dashboard')]
|
||||||
|
#[Route('/secretaire', name: 'secretaire_dashboard')]
|
||||||
|
#[Route('/chauffagiste', name: 'chauffagiste_dashboard')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
if ($this->isGranted('ROLE_ADMIN')) {
|
if ($this->isGranted('ROLE_ADMIN')) {
|
||||||
return $this->render('admin.html.twig');
|
return $this->render('dashboard/admin.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isGranted('ROLE_SECRETAIRE')) {
|
if ($this->isGranted('ROLE_SECRETAIRE')) {
|
||||||
return $this->render('secretaire.html.twig');
|
return $this->render('dashboard/secretaire.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isGranted('ROLE_CHAUFFAGISTE')) {
|
if ($this->isGranted('ROLE_CHAUFFAGISTE')) {
|
||||||
return $this->render('chauffagiste.html.twig');
|
return $this->render('dashboard/chauffagiste.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $this->createAccessDeniedException('Vous ne pouvez pas accéder à ce tableau de bord.');
|
throw $this->createAccessDeniedException('Vous ne pouvez pas accéder à ce tableau de bord.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user