Passed
Push — master ( b9f48d...ecf03f )
by Julito
09:42
created

SecurityController::loginAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\UserBundle\Controller;
5
6
use Chamilo\UserBundle\Form\LoginType;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * Class SecurityController.
14
 *
15
 * @package Chamilo\UserBundle\Controller
16
 */
17
class SecurityController extends Controller
18
{
19
    /**
20
     *
21
     * @Route("/login", name="login")
22
     *
23
     * @return Response
24
     */
25
    public function loginAction()
26
    {
27
        $helper = $this->get('security.authentication_utils');
28
        $error = $helper->getLastAuthenticationError();
29
30
        $form = $this->createForm(LoginType::class, ['_username' => $helper->getLastUsername()]);
31
32
        return $this->render('@ChamiloUser/login.html.twig', [
33
            'last_username' => $helper->getLastUsername(),
34
            'error' => $error,
35
            'form' => $form->createView(),
36
        ]);
37
    }
38
39
    /**
40
     * Used in the home page
41
     * @return Response
42
     */
43
    public function loginSideBarAction()
44
    {
45
        $helper = $this->get('security.authentication_utils');
46
47
        $form = $this->createForm(LoginType::class, ['_username' => $helper->getLastUsername()]);
48
49
        return $this->render('@ChamiloUser/login_sidebar.html.twig', [
50
            'last_username' => $helper->getLastUsername(),
51
            'error' => '', // error will be printed in the /login page
52
            'form' => $form->createView(),
53
        ]);
54
    }
55
}
56