1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace FSi\Bundle\AdminSecurityBundle\Controller; |
11
|
|
|
|
12
|
|
|
use FSi\Bundle\AdminBundle\Message\FlashMessages; |
13
|
|
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; |
14
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; |
15
|
|
|
|
16
|
|
|
class SecurityController |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var EngineInterface |
20
|
|
|
*/ |
21
|
|
|
private $templating; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var AuthenticationUtils |
25
|
|
|
*/ |
26
|
|
|
private $authenticationUtils; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var FlashMessages |
30
|
|
|
*/ |
31
|
|
|
private $flashMessages; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $loginActionTemplate; |
37
|
|
|
|
38
|
|
|
public function __construct( |
39
|
|
|
EngineInterface $templating, |
40
|
|
|
AuthenticationUtils $authenticationUtils, |
41
|
|
|
FlashMessages $flashMessages, |
42
|
|
|
string $loginActionTemplate |
43
|
|
|
) { |
44
|
|
|
$this->templating = $templating; |
45
|
|
|
$this->authenticationUtils = $authenticationUtils; |
46
|
|
|
$this->flashMessages = $flashMessages; |
47
|
|
|
$this->loginActionTemplate = $loginActionTemplate; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function loginAction() |
51
|
|
|
{ |
52
|
|
|
$error = $this->authenticationUtils->getLastAuthenticationError(); |
53
|
|
|
if ($error) { |
54
|
|
|
$this->flashMessages->error( |
55
|
|
|
$error->getMessageKey(), |
56
|
|
|
$error->getMessageData(), |
57
|
|
|
'security' |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $this->templating->renderResponse( |
62
|
|
|
$this->loginActionTemplate, |
63
|
|
|
['last_username' => $this->authenticationUtils->getLastUsername()] |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|