src/Controller/SecurityController.php line 33

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\Response;
  4. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  5. class SecurityController extends BaseAbstractController
  6. {
  7.     public function login(AuthenticationUtils $authenticationUtils): Response
  8.     {
  9.         if ($this->getUser()) {
  10.             return $this->redirectToRoute('index');
  11.         }
  12.         $error $authenticationUtils->getLastAuthenticationError();
  13.         $lastUsername $authenticationUtils->getLastUsername();
  14.         if ($error) {
  15.             switch ($error->getMessage()) {
  16.                 case "The presented password is invalid.":
  17.                     $error 'Неверный логин или пароль';
  18.                     break;
  19.                 default:
  20.                     $error $error->getMessage();
  21.             }
  22.             //  $this->addFlash('errors', $error->getMessage());
  23.              $this->addFlash('errors'$error);
  24.         }
  25.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername]);
  26.     }
  27.     
  28.     public function logout(): void
  29.     {
  30.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  31.     }
  32. }