<?php
namespace App\Controller\Auth\App;
use App\Entity\App\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
* Class SecurityController
*
* @package App\Controller
*/
class SecurityController extends AbstractController
{
/**
* @Route("/{_locale}/login", name="login", requirements={"_locale": "\w{2}"})
*
* @param AuthenticationUtils $authenticationUtils
*
* @return Response
*/
public function login(AuthenticationUtils $authenticationUtils): Response
{
if($this->getUser() instanceof User) {
return $this->redirectToRoute('public_index');
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render('Auth/App/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error
]);
}
/**
* @Route("/login")
*
* @return Response
*/
public function redirectToLogin()
{
if($this->getUser() instanceof User) {
return $this->redirectToRoute('public_index');
}
return $this->redirectToRoute('login');
}
/**
* @Route("/logout", name="logout", methods={"GET"})
*/
public function logout()
{
}
}