/**
  * This is called when an interactive authentication attempt fails. This is
  * called by authentication listeners inheriting from
  * AbstractAuthenticationListener.
  *
  * @param Request                 $request
  * @param AuthenticationException $exception    
  * @return Response the response to return
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         $result = array('success' => false, 'message' => $exception->getMessage());
         $response = new Response(json_encode($result));
         $response->headers->set('Content-Type', 'application/json');
         return $response;
     } else {
         echo "Not allowed";
     }
 }
Exemplo n.º 2
0
 public function testConstructor()
 {
     $authenticationException = new AuthenticationException(AuthenticationException::AUTHENTICATION_ERROR, ['consumer_id' => 1, 'resources' => 'record2']);
     $this->assertSame('An authentication error occurred.', $authenticationException->getMessage());
 }