Completed
Push — master ( e79dfa...ffecda )
by Benjamin
02:16
created

AuthenticationHandler   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onAuthenticationSuccess() 0 10 3
1
<?php
2
3
namespace Alpixel\Bundle\UserBundle\Handler;
4
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\RedirectResponse;
7
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
8
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
9
use Symfony\Bundle\FrameworkBundle\Routing\Router;
10
11
class AuthenticationHandler implements AuthenticationSuccessHandlerInterface
12
{
13
    protected $router;
14
15
    public function __construct(Router $router)
16
    {
17
        $this->router = $router;
18
    }
19
20
    public function onAuthenticationSuccess(Request $request, TokenInterface $token)
21
    {
22
        $back = $request->get('back');
23
24
        if (!empty($back) && $back != "/404") {
25
            return new RedirectResponse($back);
26
        }
27
28
        return new RedirectResponse($this->router->generate('front_home'));
29
    }
30
}
31