<?php
/**
* Created by PhpStorm.
* User: vad
* Date: 9/5/18
* Time: 10:12 PM
*/
namespace App\Controller\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController
{
/**
* @Route("/login", name="login")
* @param Request $request
* @param SessionInterface $session
* @param AuthenticationUtils $authenticationUtils
* @return array
* @Template("registry/login.html.twig")
*/
public function login(Request $request,
SessionInterface $session,
AuthenticationUtils $authenticationUtils): array
{
if ($request->query->has('doctor-id')) {
$session->set('doctor-id', $request->query->get('doctor-id'));
}
if ($request->query->has('appointment-date')) {
$session->set('appointment-date', $request->query->get('appointment-date'));
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return [
'last_username' => $lastUsername,
'error' => $error,
];
}
/**
* @Route("administration/login", name="administration-login")
* @param AuthenticationUtils $authenticationUtils
* @Template("administration/login.html.twig")
* @return array
*/
public function administrationLogin(AuthenticationUtils $authenticationUtils)
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return [
'last_username' => $lastUsername,
'error' => $error,
];
}
/**
* @Route("registry-administration/login", name="registry-administration-login")
* @param AuthenticationUtils $authenticationUtils
* @Template("registry-administration/login.html.twig")
* @return array
*/
public function registryAdministrationLogin(AuthenticationUtils $authenticationUtils)
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return [
'last_username' => $lastUsername,
'error' => $error,
];
}
/**
* @Route("doctor/login", name="doctor-login")
* @param AuthenticationUtils $authenticationUtils
* @Template("doctor/login.html.twig")
* @return array
*/
public function doctorLogin(AuthenticationUtils $authenticationUtils)
{
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return [
'last_username' => $lastUsername,
'error' => $error,
];
}
}