src/Security/Listener/CasLogoutListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Security\Listener;
  3. use App\Security\KuAuth;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\Security\Http\Event\LogoutEvent;
  6. class CasLogoutListener
  7. {
  8.     private $kuAuth;
  9.     public function __construct(KuAuth $kuAuth)
  10.     {
  11.         $this->kuAuth $kuAuth;
  12.     }
  13.     public function __invoke(LogoutEvent $event): void
  14.     {
  15.         if ($event->getToken()->hasAttribute($this->kuAuth->session_key())) {
  16.             $path $this->kuAuth->logout_without_redirect();
  17.             $event->setResponse(new RedirectResponse($path));
  18.         }
  19.     }
  20. }