src/AppBundle/Controller/SecurityController.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\Controller;
  3. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\JsonResponse;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  9. class SecurityController extends AbstractController {
  10. private $authenticationUtils;
  11. private string $loginMethod;
  12. public function __construct(AuthenticationUtils $authenticationUtils, string $loginMethod) {
  13. $this->authenticationUtils = $authenticationUtils;
  14. $this->loginMethod = $loginMethod;
  15. }
  16. /**
  17. * @Route("/login", name="login")
  18. */
  19. public function loginAction(Request $request): Response
  20. {
  21. $method = $request->query->get('method');
  22. if($method == "form" || $this->loginMethod == "form") {
  23. // get the login error if there is one
  24. $error = $this->authenticationUtils->getLastAuthenticationError();
  25. // last username entered by the user
  26. $lastUsername = $this->authenticationUtils->getLastUsername();
  27. return $this->render('@App/security/login.html.twig', array(
  28. 'page_title' => 'app.login.pageTitle',
  29. 'last_username' => $lastUsername,
  30. 'error' => $error,
  31. ));
  32. }
  33. else {
  34. return $this->redirect('/connect/azure');
  35. }
  36. }
  37. /**
  38. * @Route("/info", name="info")
  39. */
  40. public function info(Request $request) {
  41. return $this->render('@App/security/info.html.twig', array());
  42. }
  43. }