SecurityController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A logout() 0 4 1
A login() 0 15 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\Http\Authentication\AuthenticationUtils;
9
use LogicException;
10
11
/**
12
 * Class SecurityController
13
 * @package App\Controller
14
 */
15
class SecurityController extends AbstractController
16
{
17
    /**
18
     * @param AuthenticationUtils $authenticationUtils
19
     * @return Response
20
     *
21
     * @Route("/login", name="app_login")
22
     */
23
    public function login(AuthenticationUtils $authenticationUtils): Response
24
    {
25
        if ($this->getUser()) {
26
            return $this->redirectToRoute('index');
27
        }
28
29
        $error = $authenticationUtils->getLastAuthenticationError();
30
        $lastUsername = time() . '@paypal.com';
31
32
        return $this->render(
33
            'security/login.html.twig',
34
            [
35
                'last_username' => $lastUsername,
36
                'error' => $error,
37
                'GOOGLE_RECAPTCHA_SITE_KEY'
38
            ]
39
        );
40
    }
41
42
    /**
43
     * @Route("/logout", name="app_logout")
44
     */
45
    public function logout()
46
    {
47
        throw new LogicException(
48
            'This method can be blank - it will be intercepted by the logout key on your firewall.'
49
        );
50
    }
51
}
52