SecurityController::logout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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