<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends BaseAbstractController
{
public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('index');
}
$error = $authenticationUtils->getLastAuthenticationError();
$lastUsername = $authenticationUtils->getLastUsername();
if ($error) {
switch ($error->getMessage()) {
case "The presented password is invalid.":
$error = 'Неверный логин или пароль';
break;
default:
$error = $error->getMessage();
}
// $this->addFlash('errors', $error->getMessage());
$this->addFlash('errors', $error);
}
return $this->render('security/login.html.twig', ['last_username' => $lastUsername]);
}
public function logout(): void
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}