<?php
namespace App\Controller\Kernel;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use App\Service\Kernel\KernelService;
/**
* @Route("/{_locale}")
*/
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="app_login")
*/
public function login(AuthenticationUtils $authenticationUtils, KernelService $kernelService): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('app_home', ['_locale' => "".$this->getUser()->getLocale()]);
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
$error2 = $this->container->get('session')->get('error');
$this->container->get('session')->remove('error');
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
$facebook = $kernelService->getApplicationInfoValue("Kernel.LoginWithFacebook");
$office356 = $kernelService->getApplicationInfoValue("Kernel.LoginWithOffice365");
return $this->render('security/login.html.twig',
['last_username' => $lastUsername, 'error' => $error, 'error2' => $error2,
'facebook' => $facebook, 'office365' => $office356]
);
}
/**
* @Route("/logout", name="app_logout")
*/
public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}