src/Controller/SecurityController.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Core\Controller\BaseAbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  6. class SecurityController extends BaseAbstractController
  7. {
  8.     public function login(AuthenticationUtils $authenticationUtils): Response
  9.     {
  10.         if ($this->getUser()) {
  11.             return $this->redirectToRoute('index');
  12.         }
  13.         $error $authenticationUtils->getLastAuthenticationError();
  14.         $lastUsername $authenticationUtils->getLastUsername();
  15.         if ($error) {
  16.             switch ($error->getMessage()) {
  17.                 case "The presented password is invalid.":
  18.                     $error 'Неверный логин или пароль';
  19.                     break;
  20.                 default:
  21.                     $error $error->getMessage();
  22.             }
  23.             //  $this->addFlash('errors', $error->getMessage());
  24.              $this->addFlash('errors'$error);
  25.         }
  26.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername]);
  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. }