<?php
namespace App\Security\Listener;
use App\Security\KuAuth;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Http\Event\LogoutEvent;
class CasLogoutListener
{
private $kuAuth;
public function __construct(KuAuth $kuAuth)
{
$this->kuAuth = $kuAuth;
}
public function __invoke(LogoutEvent $event): void
{
if ($event->getToken()->hasAttribute($this->kuAuth->session_key())) {
$path = $this->kuAuth->logout_without_redirect();
$event->setResponse(new RedirectResponse($path));
}
}
}