<?php
namespace App\AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class SecurityController extends AbstractController {
private $authenticationUtils;
private string $loginMethod;
public function __construct(AuthenticationUtils $authenticationUtils, string $loginMethod) {
$this->authenticationUtils = $authenticationUtils;
$this->loginMethod = $loginMethod;
}
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request): Response
{
$method = $request->query->get('method');
if($method == "form" || $this->loginMethod == "form") {
// get the login error if there is one
$error = $this->authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $this->authenticationUtils->getLastUsername();
return $this->render('@App/security/login.html.twig', array(
'page_title' => 'app.login.pageTitle',
'last_username' => $lastUsername,
'error' => $error,
));
}
else {
return $this->redirect('/connect/azure');
}
}
/**
* @Route("/info", name="info")
*/
public function info(Request $request) {
return $this->render('@App/security/info.html.twig', array());
}
}