diff --git a/Event/LogoutWithServiceSuccessHandler.php b/Event/LogoutWithServiceSuccessHandler.php new file mode 100644 index 0000000..5eb2c63 --- /dev/null +++ b/Event/LogoutWithServiceSuccessHandler.php @@ -0,0 +1,91 @@ +router = $router; + $this->casLogoutUrl = $casLogoutUrl; + $this->routeName = $routeName; + $this->routeParameters = $routeParameters; + } + + /** + * Redirects to the CAS server, but with a service parameter that directs the + * user back here if they wish. + */ + public function onLogoutSuccess(Request $request) + { + $serviceUrl = $this->router->generate($this->routeName, $this->routeParameters, RouterInterface::ABSOLUTE_URL); + + return new RedirectResponse($this->casLogoutUrl.'?'.http_build_query(['service' => $serviceUrl])); + } +}