Completed
Push — Recipes ( c0466a...7632b6 )
by Laurent
04:22
created

SecurityController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A logout() 0 3 1
A login() 0 10 1
1
<?php
2
/**
3
 * SecurityController Controller of App security.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2018 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: $Id$
12
 *
13
 * @see https://github.com/Dev-Int/glsr
14
 */
15
16
namespace App\Controller;
17
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\Routing\Annotation\Route;
20
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
21
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
22
23
class SecurityController extends AbstractController
24
{
25
    /**
26
     * @Route("/login", name="app_login", methods={"GET"})
27
     */
28
    public function login(AuthenticationUtils $authenticationUtils): Response
29
    {
30
        // get the login error if there is one
31
        $error = $authenticationUtils->getLastAuthenticationError();
32
        // last username entered by the user
33
        $lastUsername = $authenticationUtils->getLastUsername();
34
35
        return $this->render('security/login.html.twig', [
36
            'last_username' => $lastUsername,
37
            'error' => $error
38
        ]);
39
    }
40
41
    /**
42
     * @Route("/logout", name="app_logout", methods={"GET"})
43
     */
44
    public function logout()
45
    {
46
        throw new \Exception('Don\'t forget to activate logout in security.yaml');
47
    }
48
}
49