Completed
Push — symfony-3.3 ( e8b928...951e26 )
by Kamil
24:54 queued 03:04
created

AuthenticationSuccessHandler::determineTargetUrl()   C

Complexity

Conditions 8
Paths 5

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 6.6037
cc 8
eloc 11
nc 5
nop 1
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
18
/**
19
 * @author Arkadiusz Krakowiak <[email protected]>
20
 */
21
final class AuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
27
    {
28
        if ($request->isXmlHttpRequest()) {
29
            return new JsonResponse(['success' => true, 'username' => $token->getUsername()]);
30
        }
31
32
        return parent::onAuthenticationSuccess($request, $token);
33
    }
34
}
35