<?php
namespace App\Controller;
use App\Service\Exceptions\LogoutException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="login")
* @param Request $request
* @param AuthenticationUtils $authUtils
* @return Response
*/
public function login(Request $request, AuthenticationUtils $authUtils)
{
$error = $authUtils->getLastAuthenticationError();
$lastUsername = $authUtils->getLastUsername();
if($error == NULL){
$error = array('messageKey' => '', 'messageData' => array());
}
return $this->render('security/login.html.twig', array(
'last_username' => $lastUsername,
'error' => $error,
));
}
/**
* @Route("/logout", methods={"GET"})
* @throws LogoutException
*/
public function logout()
{
throw new LogoutException('Don\'t forget to activate logout in security.yaml');
}
}