src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
    {
        if ($request->isXmlHttpRequest()) {
            // if AJAX login
            $array = ['message' => $exception->getMessage()];
            $response = new JsonResponse($array, 401);
        } else {
            // if form login
            // set authentication exception to session
            $this->session->set(Security::AUTHENTICATION_ERROR, $exception);
            $response = new RedirectResponse($this->router->generate('sulu_admin.login'));
        }

        return $response;
    }
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
    {
        if ($request->isXmlHttpRequest()) {
            // if AJAX login
            $array = ['message' => $exception->getMessage()];
            $response = new JsonResponse($array, 401);
        } else {
            // if form login
            // set authentication exception to session
            $this->session->set(Security::AUTHENTICATION_ERROR, $exception);
            $response = new RedirectResponse($this->router->generate('sulu_admin.login'));
        }

        return $response;
    }
public function onAuthenticationFailure ( Request $ request , AuthenticationException $ exception ) { if ( $ request -> isXmlHttpRequest ( ) ) { // if AJAX login $ array = [ 'message' => $ exception -> getMessage ( ) ] ; $ response = new JsonResponse ( $ array , 401 ) ; } else { // if form login // set authentication exception to session $ this -> session -> set ( Security :: AUTHENTICATION_ERROR , $ exception ) ; $ response = new RedirectResponse ( $ this -> router -> generate ( 'sulu_admin.login' ) ) ; } return $ response ; }
Handler for AuthenticationFailure. Returns a JsonResponse if request is an AJAX-request.
Returns a Redirect-response otherwise.

@param Request $request
@param AuthenticationException $exception

@return Response
Handler for AuthenticationFailure . Returns a JsonResponse if request is an AJAX - request . Returns a Redirect - response otherwise .