src/Controller/Utilisateurs/LoginController.php line 27
<?php
namespace App\Controller\Utilisateurs;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* Authentication Controller*
* Class LoginController
*
* @package App\Controller\Utilisateurs\Login
*/
class LoginController extends AbstractController
{
/**
* User Login
*
* @param AuthenticationUtils $authenticationUtils
* @return Response
*
* @Route("/login", name="login", methods={"GET","POST"})
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {
return $this->redirectToRoute('app_home');
} else {
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('users/login.html.twig', [
'controller_name' => 'LoginController',
'last_username' => $lastUsername,
'error' => $error,
]);
}
}
/**
* User Logout
*
* @Route("/logout", name="logout", methods={"GET"})
*/
#[IsGranted('ROLE_USER')]
public function logout(): void
{
}
}