Completed
Push — master ( 96ea8b...1276b9 )
by Alexis
08:08
created

AuthController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A loginAction() 0 13 3
1
<?php
2
3
/*
4
 * This file is part of the awurth/silex-user package.
5
 *
6
 * (c) Alexis Wurth <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AWurth\Silex\User\Controller;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\Security\Core\Security;
16
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
17
18
/**
19
 * Silex User Authentication Controller.
20
 *
21
 * @author Alexis Wurth <[email protected]>
22
 */
23
class AuthController extends Controller
24
{
25
    public function loginAction(Request $request)
26
    {
27
        $csrfToken = null;
28
        if (isset($this->application['csrf.token_manager']) && $this->application['csrf.token_manager'] instanceof CsrfTokenManagerInterface) {
29
            $csrfToken = $this->application['csrf.token_manager']->getToken('authenticate');
30
        }
31
32
        return $this->render('silex_user/auth/login.twig', [
33
            'error'         => $this->application['security.last_error']($request),
34
            'last_username' => $this->application['session']->get(Security::LAST_USERNAME),
35
            'csrf_token' => $csrfToken
36
        ]);
37
    }
38
}
39