|
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
|
|
|
|