+ /**
+ * Process a response for the single logout service.
+ * @throws Error
+ */
+ public function processSlsResponse(?string $requestId): ?string
+ {
+ $toolkit = $this->getToolkit();
+ $redirect = $toolkit->processSLO(true, $requestId, false, null, true);
+
+ $errors = $toolkit->getErrors();
+
+ if (!empty($errors)) {
+ throw new Error(
+ 'Invalid SLS Response: '.implode(', ', $errors)
+ );
+ }
+
+ $this->actionLogout();
+ return $redirect;
+ }
+
+ /**
+ * Do the required actions to log a user out.
+ */
+ protected function actionLogout()
+ {
+ auth()->logout();
+ session()->invalidate();
+ }
+