Completed
Pull Request — master (#2737)
by Jeroen
17:30 queued 02:36
created

SecurityController::logoutAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Kunstmaan\AdminBundle\Controller\Authentication;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use Symfony\Component\Routing\Annotation\Route;
7
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
8
use Twig\Environment;
9
10
final class SecurityController
11
{
12
    /** @var AuthenticationUtils */
13
    private $authenticationUtils;
14
    /** @var Environment */
15
    private $twig;
16
17
    public function __construct(AuthenticationUtils $authenticationUtils, Environment $twig)
18
    {
19
        $this->authenticationUtils = $authenticationUtils;
20
        $this->twig = $twig;
21
    }
22
23
    /**
24
     * @Route("/login", name="cms_login", methods={"GET", "POST"})
25
     * @Route("/login", name="fos_user_security_login", methods={"GET", "POST"})
26
     */
27
    public function loginAction()
28
    {
29
        $error = $this->authenticationUtils->getLastAuthenticationError();
30
        $lastUsername = $this->authenticationUtils->getLastUsername();
31
32
        return new Response($this->twig->render('@KunstmaanAdmin/authentication/login.html.twig', [
33
            'last_username' => $lastUsername,
34
            'error' => $error,
35
        ]));
36
    }
37
38
    /**
39
     * @Route("/logout", name="cms_logout")
40
     * @Route("/logout", name="fos_user_security_logout")
41
     */
42
    public function logoutAction()
43
    {
44
        throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
45
    }
46
}
47