src/Client/Controller/ClientSecurityController.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Client\Controller;
  3. use App\Entity\ManagerAccount;
  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 App\Kb\Admin\BaseBundle\Controller\SecurityController;
  10. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  11. use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
  12. use Doctrine\Persistence\ManagerRegistry;
  13. class ClientSecurityController extends SecurityController
  14. {
  15.     protected $token;
  16.     protected $admin;
  17.     protected $doctrine;
  18.     public function __construct(TokenStorageInterface $tokenStorageManagerRegistry $doctrine)
  19.     {
  20.         $this->token $tokenStorage->getToken();
  21.         if(!empty($this->token)){
  22.             $this->admin $this->token->getUser();
  23.         }
  24.         $this->doctrine $doctrine;
  25.     }
  26.     /**
  27.      * @Route("/", name="client_login")
  28.      */
  29.     public function login(AuthenticationUtils $authenticationUtils): Response
  30.     {
  31.         // if ($this->getUser()) {
  32.         //     return $this->redirectToRoute('target_path');
  33.         // }
  34.         // 
  35.         // get the login error if there is one
  36.         $error $authenticationUtils->getLastAuthenticationError();
  37.         // last username entered by the user
  38.         $lastUsername $authenticationUtils->getLastUsername();
  39.         return $this->render('client_security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  40.     }
  41.     /**
  42.      * @Route("/client_logout", name="client_logout")
  43.      */
  44.     public function logout()
  45.     {
  46.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  47.         return $this->redirectToRoute('client_logout');
  48.     }
  49. }