Completed
Push — master ( 4c7b9c...e919dc )
by Kamil
21:11
created

AuthenticationSuccessHandler   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 14
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A onAuthenticationSuccess() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
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 Sylius\Bundle\UserBundle\Authentication;
13
14
use Symfony\Component\HttpFoundation\JsonResponse;
15
use Symfony\Component\HttpFoundation\Request;
16
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler;
18
19
/**
20
 * @author Arkadiusz Krakowiak <[email protected]>
21
 */
22
class AuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
28
    {
29
        if ($request->isXmlHttpRequest()) {
30
            return new JsonResponse(['success' => true, 'username' => $token->getUsername()]);
31
        }
32
33
        return parent::onAuthenticationSuccess($request, $token);
34
    }
35
}
36