Skip to content

Instantly share code, notes, and snippets.

View stollr's full-sized avatar

Christian Stoller stollr

View GitHub Profile
@stollr
stollr / AjaxAuthenticationListener.php
Last active August 29, 2015 14:02 — forked from xanf/AjaxAuthenticationListener.php
How to register an Symfony event handler to prevent JSON/AJAX requests to be redirected
<?php
namespace Acme\Bundle\MyBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
class AjaxAuthenticationListener
{