<?php
namespace App\Controller;
use LogicException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class AuthController extends AbstractController
{
/**
* @Route("/login", name="auth_login")
* @Template()
*/
public function login(AuthenticationUtils $utils)
{
if ($this->getUser()) return $this->redirectToRoute('home_index');
$error = $utils->getLastAuthenticationError();
$lastUsername = $utils->getLastUsername();
return [
'error' => $error,
'last_username' => $lastUsername
];
}
/**
* @Route("/logout", name="auth_logout")
*/
public function logout(): array
{
throw new LogicException(
'This method can be blank - it will be intercepted by the logout key on your firewall.'
);
}
}