Author: Fabien Potencier (fabien@symfony.com)
 protected function setTargetPath(Request $request)
 {
     if ($request->isXmlHttpRequest()) {
         return;
     }
     parent::setTargetPath($request);
 }
Example #2
0
 protected function setTargetPath(Request $request)
 {
     // Do not save target path for oauth registration
     if (preg_match('{^/connect/registration}', $request->getPathInfo())) {
         return;
     }
     parent::setTargetPath($request);
 }
 protected function setTargetPath(Request $request)
 {
     // Do not save target path for XHR requests
     // You can add any more logic here you want
     // Note that non-GET requests are already ignored
     if ($request->isXmlHttpRequest()) {
         return;
     }
     parent::setTargetPath($request);
 }
 /**
  * @param $request Request
  *
  * @return void
  */
 protected function setTargetPath(Request $request)
 {
     // Do not save target path for non HTML requests
     // Note that non-GET requests are already ignored
     $acceptableContentTypes = array_map('strtolower', $request->getAcceptableContentTypes());
     if (!in_array('text/html', $acceptableContentTypes) || $request->isXmlHttpRequest()) {
         return;
     }
     parent::setTargetPath($request);
 }
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $responseType = function () use($event) {
         $request = $event->getRequest();
         $accepts = $request->headers->get('accept', null);
         $contentType = $request->getContentType();
         return $accepts ? $accepts : $contentType;
     };
     if (strstr($responseType(), 'application/json') !== false) {
         $e = $event->getException();
         $response = new JsonResponse();
         $code = 500;
         if ($e instanceof NotFoundHttpException) {
             $code = 404;
         }
         if ($e instanceof AccessDeniedException) {
             $code = 403;
         }
         $response->setContent(json_encode(['error' => $e->getMessage(), 'code' => $code], true))->setStatusCode($code);
         $event->setResponse($response);
     } else {
         parent::onKernelException($event);
     }
 }
Example #6
0
 public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
 {
     $this->providerKey = $providerKey;
     parent::__construct($context, $trustResolver, $httpUtils, $providerKey, $authenticationEntryPoint, $errorPage, $accessDeniedHandler, $logger);
 }