<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class AccountController extends AbstractController
{
/**
* Formulaire de connexion
*
* @Route("/login", name="account_login")
*
* @param AuthenticationUtils $utils
* @return Response
*/
public function login(AuthenticationUtils $utils): Response
{
$error = $utils->getLastAuthenticationError();
$username = $utils->getLastUsername();
if ($this->isGranted('ROLE_ADMIN') or $this->isGranted('ROLE_USER')) {
return $this->redirectToRoute('home');
}
return $this->render('account/login.html.twig', [
'hasError' => $error!==null,
'username' => $username
]);
}
/**
* Deconnexion
*
* @Route("/logout", name="account_logout")
*
* @return void
*/
public function logout()
{
//rien
}
}