SecurityController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A login() 0 17 1
A logout() 0 4 1
1
<?php
2
3
namespace App\Controller;
4
5
use App\Form\Type\FormLoginType;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Routing\Annotation\Route;
9
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
10
11
class SecurityController extends AbstractController
12
{
13
    /**
14
     * @Route("/login", name="app_login")
15
     */
16 22
    public function login(AuthenticationUtils $authenticationUtils): Response
17
    {
18
        // if ($this->getUser()) {
19
        //     return $this->redirectToRoute('target_path');
20
        // }
21 22
        $form = $this->createForm(FormLoginType::class);
22
        // get the login error if there is one
23 22
        $error = $authenticationUtils->getLastAuthenticationError();
24
        // last username entered by the user
25 22
        $lastUsername = $authenticationUtils->getLastUsername();
26
27 22
        return $this->render('security/login.html.twig', [
28 22
            'last_username' => $lastUsername,
29 22
            'error' => $error,
30 22
            'form' => $form->createView(),
31
        ]);
32
    }
33
34
    /**
35
     * @Route("/logout", name="app_logout")
36
     */
37
    public function logout()
38
    {
39
        throw new \Exception('This method can be blank - it will be intercepted by the logout key on your firewall');
40
    }
41
}
42