src/Controller/Security/SecurityController.php line 28

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: vad
  5.  * Date: 9/5/18
  6.  * Time: 10:12 PM
  7.  */
  8. namespace App\Controller\Security;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  15. class SecurityController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("/login", name="login")
  19.      * @param Request $request
  20.      * @param SessionInterface $session
  21.      * @param AuthenticationUtils $authenticationUtils
  22.      * @return array
  23.      * @Template("registry/login.html.twig")
  24.      */
  25.     public function login(Request $request,
  26.                           SessionInterface $session,
  27.                           AuthenticationUtils $authenticationUtils): array
  28.     {
  29.         if ($request->query->has('doctor-id')) {
  30.             $session->set('doctor-id'$request->query->get('doctor-id'));
  31.         }
  32.         if ($request->query->has('appointment-date')) {
  33.             $session->set('appointment-date'$request->query->get('appointment-date'));
  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 [
  40.             'last_username' => $lastUsername,
  41.             'error'         => $error,
  42.         ];
  43.     }
  44.     /**
  45.      * @Route("administration/login", name="administration-login")
  46.      * @param AuthenticationUtils $authenticationUtils
  47.      * @Template("administration/login.html.twig")
  48.      * @return array
  49.      */
  50.     public function administrationLogin(AuthenticationUtils $authenticationUtils)
  51.     {
  52.         // get the login error if there is one
  53.         $error $authenticationUtils->getLastAuthenticationError();
  54.         // last username entered by the user
  55.         $lastUsername $authenticationUtils->getLastUsername();
  56.         return [
  57.             'last_username' => $lastUsername,
  58.             'error'         => $error,
  59.         ];
  60.     }
  61.     /**
  62.      * @Route("registry-administration/login", name="registry-administration-login")
  63.      * @param AuthenticationUtils $authenticationUtils
  64.      * @Template("registry-administration/login.html.twig")
  65.      * @return array
  66.      */
  67.     public function registryAdministrationLogin(AuthenticationUtils $authenticationUtils)
  68.     {
  69.         // get the login error if there is one
  70.         $error $authenticationUtils->getLastAuthenticationError();
  71.         // last username entered by the user
  72.         $lastUsername $authenticationUtils->getLastUsername();
  73.         return [
  74.             'last_username' => $lastUsername,
  75.             'error'         => $error,
  76.         ];
  77.     }
  78.     /**
  79.      * @Route("doctor/login", name="doctor-login")
  80.      * @param AuthenticationUtils $authenticationUtils
  81.      * @Template("doctor/login.html.twig")
  82.      * @return array
  83.      */
  84.     public function doctorLogin(AuthenticationUtils $authenticationUtils)
  85.     {
  86.         // get the login error if there is one
  87.         $error $authenticationUtils->getLastAuthenticationError();
  88.         // last username entered by the user
  89.         $lastUsername $authenticationUtils->getLastUsername();
  90.         return [
  91.             'last_username' => $lastUsername,
  92.             'error'         => $error,
  93.         ];
  94.     }
  95. }