Completed
Push — master ( affb41...f007be )
by Rafał
09:54
created

SecurityController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A login() 0 16 2
A logout() 0 4 1
1
<?php
2
3
namespace SWP\Bundle\UserBundle\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
10
class SecurityController extends AbstractController
11
{
12
    public function login(AuthenticationUtils $authenticationUtils): Response
13
    {
14
        if ($this->getUser()) {
15
            return $this->redirectToRoute('homepage');
16
        }
17
18
        // get the login error if there is one
19
        $error = $authenticationUtils->getLastAuthenticationError();
20
        // last username entered by the user
21
        $lastUsername = $authenticationUtils->getLastUsername();
22
23
        return $this->render(
24
            '@SWPUser/Security/login.html.twig',
25
            ['last_username' => $lastUsername, 'error' => $error]
26
        );
27
    }
28
29
    /**
30
     * @Route("/logout", name="swp_user_logout")
31
     */
32
    public function logout()
33
    {
34
        return new Response('');
35
    }
36
}
37