-
Notifications
You must be signed in to change notification settings - Fork 8
/
SecurityController.php
63 lines (53 loc) · 1.68 KB
/
SecurityController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
/*
* This file is part of the user bundle package.
* (c) Connect Holland.
*/
namespace ConnectHolland\UserBundle\Controller;
use ConnectHolland\UserBundle\Form\LoginType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Twig\Environment;
class SecurityController
{
/**
* @var AuthenticationUtils
*/
private $authenticationUtils;
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* @var Environment
*/
private $twig;
public function __construct(AuthenticationUtils $authenticationUtils, FormFactoryInterface $formFactory, Environment $twig)
{
$this->authenticationUtils = $authenticationUtils;
$this->formFactory = $formFactory;
$this->twig = $twig;
}
/**
* @Route("/inloggen", name="connectholland_user_login", methods={"GET", "POST"})
*/
public function __invoke(): Response
{
$form = $this->formFactory->create(LoginType::class);
$lastUsername = $this->authenticationUtils->getLastUsername();
$error = $this->authenticationUtils->getLastAuthenticationError();
return new Response(
$this->twig->render(
'@ConnecthollandUser/security/login.html.twig',
[
'form' => $form->createView(),
'last_username' => $lastUsername,
'error' => $error,
]
)
);
}
}