<?php
namespace App\BackOffice\ConfigurationBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="login")
* @Template("@BackOfficeConfiguration/Security/login.html.twig")
*/
public function loginAction(AuthenticationUtils $authenticationUtils)
{
// Si le visiteur est déjà identifié, on le redirige vers l'accueil
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
return $this->redirect($this->generateUrl('admin_home'));
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return array(
// last username entered by the user
'last_username' => $lastUsername,
'error' => $error,
);
}
}