Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SecurityController
75.00% covered (warning)
75.00%
3 / 4
50.00% covered (danger)
50.00%
1 / 2
2.06
0.00% covered (danger)
0.00%
0 / 1
 login
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 logout
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Controller;
4
5use LogicException;
6use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7use Symfony\Component\HttpFoundation\Response;
8use Symfony\Component\Routing\Annotation\Route;
9use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
10
11class SecurityController extends AbstractController
12{
13    #[Route("/login", name:"app_login")]
14    public function login(AuthenticationUtils $authenticationUtils): Response
15    {
16        // get the login error if there is one
17        $error = $authenticationUtils->getLastAuthenticationError();
18        // last username entered by the user
19        $lastUsername = $authenticationUtils->getLastUsername();
20
21        return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
22    }
23
24    #[Route("/logout", name:"app_logout")]
25    public function logout(): void
26    {
27        throw new LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
28    }
29}