Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Controller/Admin/LoginController.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Admin;
  3. use App\Service\BrandService;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. use Symfony\Component\Security\Http\Util\TargetPathTrait;
  10. class LoginController extends AbstractController
  11. {
  12.     use TargetPathTrait;
  13.     #[Route('/admin/connexion'name'admin_login')]
  14.     public function index(Request $requestAuthenticationUtils $authenticationUtilsBrandService $brandService): Response
  15.     {
  16.         if($this->getUser()) {
  17.             if($this->getUser()->isCustomer()) {
  18.                 return $this->redirectToRoute('app_account');
  19.             } else {
  20.                 return $this->redirectToRoute('admin_dashboard');
  21.             }
  22.         }
  23.         $error $authenticationUtils->getLastAuthenticationError();
  24.         $lastUsername $authenticationUtils->getLastUsername();
  25.         $redirectRoute $this->getTargetPath($request->getSession(), 'admin_secured_area');
  26.         return $this->render('admin/login.html.twig', [
  27.             'error' => $error,
  28.             'last_username' => $lastUsername,
  29.             'translation_domain' => 'admin',
  30.             'csrf_token_intention' => 'authenticate',
  31.             'target_path' => $redirectRoute ?: $this->generateUrl('admin_dashboard'),
  32.             'username_label' => "Identifiant",
  33.             'password_label' => 'Mot de passe',
  34.             'sign_in_label' => 'Se connecter',
  35.             'page_title' => 'Administration',
  36.             'logo_filename' => $brandService->getBrand()->getLogo()
  37.         ]);
  38.     }
  39.     #[Route('/admin/logout'name'admin_logout')]
  40.     public function logout(): void
  41.     {
  42.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  43.     }
  44. }