Passed
Push — develop ( 710e27...6f29be )
by Stone
03:28
created

SecurityController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A login() 0 12 2
1
<?php
2
3
namespace App\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\Routing\Annotation\Route;
8
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
9
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
10
11
class SecurityController extends AbstractController
12
{
13
    /**
14
     * @Route("/login", name="app_login")
15
     */
16
    public function login(AuthenticationUtils $authenticationUtils, AuthorizationCheckerInterface $authChecker): Response
17
    {
18
        if ($authChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
19
            return $this->redirectToRoute('trick.home');
20
        }
21
22
        // get the login error if there is one
23
        $error = $authenticationUtils->getLastAuthenticationError();
24
        // last username entered by the user
25
        $lastUsername = $authenticationUtils->getLastUsername();
26
27
        return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
28
    }
29
}
30