Passed
Push — develop ( 370f48...cc396d )
by Laurent
07:33 queued 04:53
created

SecurityController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A login() 0 12 2
A logout() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the G.L.S.R. Apps package.
7
 *
8
 * (c) Dev-Int Création <[email protected]>.
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Core\Infrastructure\Controller;
15
16
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
19
20
final class SecurityController extends AbstractController
21
{
22
    public function login(AuthenticationUtils $authenticationUtils): Response
23
    {
24
        if ($this->getUser()) {
25
            return $this->redirectToRoute('admin_index');
26
        }
27
28
        $error = $authenticationUtils->getLastAuthenticationError();
29
        $lastUsername = $authenticationUtils->getLastUsername();
30
31
        return $this->render('security/login.html.twig', [
32
            'last_username' => $lastUsername,
33
            'error' => $error,
34
        ]);
35
    }
36
37
    public function logout(): void
38
    {
39
        throw new \LogicException(
40
            'This method can be blank - it will be intercepted by the logout key on your firewall.'
41
        );
42
    }
43
}
44