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
<?php
namespace App\Controller\Admin ;
use App\Service\BrandService ;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController ;
use Symfony\Component\HttpFoundation\Request ;
use Symfony\Component\HttpFoundation\Response ;
use Symfony\Component\Routing\Annotation\Route ;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils ;
use Symfony\Component\Security\Http\Util\TargetPathTrait ;
class LoginController extends AbstractController
{
use TargetPathTrait ;
#[Route ( '/admin/connexion' , name : 'admin_login' )]
public function index ( Request $request , AuthenticationUtils $authenticationUtils , BrandService $brandService ): Response
{
if($this -> getUser ()) {
if($this -> getUser ()-> isCustomer ()) {
return $this -> redirectToRoute ( 'app_account' );
} else {
return $this -> redirectToRoute ( 'admin_dashboard' );
}
}
$error = $authenticationUtils -> getLastAuthenticationError ();
$lastUsername = $authenticationUtils -> getLastUsername ();
$redirectRoute = $this -> getTargetPath ( $request -> getSession (), 'admin_secured_area' );
return $this -> render ( 'admin/login.html.twig' , [
'error' => $error ,
'last_username' => $lastUsername ,
'translation_domain' => 'admin' ,
'csrf_token_intention' => 'authenticate' ,
'target_path' => $redirectRoute ?: $this -> generateUrl ( 'admin_dashboard' ),
'username_label' => "Identifiant" ,
'password_label' => 'Mot de passe' ,
'sign_in_label' => 'Se connecter' ,
'page_title' => 'Administration' ,
'logo_filename' => $brandService -> getBrand ()-> getLogo ()
]);
}
#[Route ( '/admin/logout' , name : 'admin_logout' )]
public function logout (): void
{
throw new \LogicException ( 'This method can be blank - it will be intercepted by the logout key on your firewall.' );
}
}