src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        // get url to redirect (or return in the JSON-response)
        if ($this->session->get('_security.admin.target_path')
            && false !== strpos($this->session->get('_security.admin.target_path'), '#')
        ) {
            $url = $this->session->get('_security.admin.target_path');
        } else {
            $url = $this->router->generate('sulu_admin');
        }

        if ($request->isXmlHttpRequest()) {
            // if AJAX login
            $array = ['url' => $url];
            $response = new JsonResponse($array, 200);
        } else {
            // if form login
            $response = new RedirectResponse($url);
        }

        return $response;
    }
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
    {
        // get url to redirect (or return in the JSON-response)
        if ($this->session->get('_security.admin.target_path')
            && false !== strpos($this->session->get('_security.admin.target_path'), '#')
        ) {
            $url = $this->session->get('_security.admin.target_path');
        } else {
            $url = $this->router->generate('sulu_admin');
        }

        if ($request->isXmlHttpRequest()) {
            // if AJAX login
            $array = ['url' => $url];
            $response = new JsonResponse($array, 200);
        } else {
            // if form login
            $response = new RedirectResponse($url);
        }

        return $response;
    }
public function onAuthenticationSuccess ( Request $ request , TokenInterface $ token ) { // get url to redirect (or return in the JSON-response) if ( $ this -> session -> get ( '_security.admin.target_path' ) && false !== strpos ( $ this -> session -> get ( '_security.admin.target_path' ) , '#' ) ) { $ url = $ this -> session -> get ( '_security.admin.target_path' ) ; } else { $ url = $ this -> router -> generate ( 'sulu_admin' ) ; } if ( $ request -> isXmlHttpRequest ( ) ) { // if AJAX login $ array = [ 'url' => $ url ] ; $ response = new JsonResponse ( $ array , 200 ) ; } else { // if form login $ response = new RedirectResponse ( $ url ) ; } return $ response ; }
Handler for AuthenticationSuccess. Returns a JsonResponse if request is an AJAX-request.
Returns a RedirectResponse otherwise.

@param Request $request
@param TokenInterface $token

@return Response
Handler for AuthenticationSuccess . Returns a JsonResponse if request is an AJAX - request . Returns a RedirectResponse otherwise .