src/Controller/Auth/AuthController.php line 14
<?php
namespace App\Controller\Auth;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class AuthController extends AbstractController
{
#[Route('/', name: 'customer.login')]
public function customerLogin(AuthenticationUtils $authenticationUtils): Response
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('login/frontend-login.html.twig', [
'_username' => $lastUsername,
'error' => $error
]);
}
#[Route('/customer/logout', name: 'customer.logout')]
public function logout(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('login/frontend-login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
#[Route('/admin', name: 'admin.login')]
public function index(AuthenticationUtils $authenticationUtils): Response
{
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('login/admin-login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]);
}
#[Route('/admin/logout', name: 'admin.logout')]
public function adminLogout(Security $security): Response
{
return $this->redirectToRoute('admin.login');
}
}