From c144bb25d4b3c831d11c98e31e91ac9d172f2073 Mon Sep 17 00:00:00 2001 From: Teddy Brown Date: Mon, 15 Jun 2020 15:47:18 -0400 Subject: [PATCH] Add LogoutWithServiceSuccessHandler.php --- Event/LogoutWithServiceSuccessHandler.php | 91 +++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Event/LogoutWithServiceSuccessHandler.php 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])); + } +}