-
Notifications
You must be signed in to change notification settings - Fork 26
refactor: delegate logout handling from login.php to LoginService #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: FRAMEWORK_6_0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -416,6 +416,24 @@ public function performLogout(LogoutRequest $request): array | |
| ); | ||
| } | ||
|
|
||
| // Run pre-logout handlers before the session is destroyed. | ||
| // A failing handler must never prevent the logout from completing. | ||
| $postLogoutRedirect = null; | ||
| if ($currentUser) { | ||
| foreach ($this->preLogoutHandlers as $handler) { | ||
|
jcdelepine marked this conversation as resolved.
|
||
| try { | ||
| $data = $handler->onBeforeLogout($currentUser, $request->reason); | ||
| if (!empty($data['redirect']) && $postLogoutRedirect === null) { | ||
| $postLogoutRedirect = $data['redirect']; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if we have multiple preLogoutHandlers with different redirect attributes? Only the first one will be honored (which is probably what we want OR notice we have contradicting setups and just crash with a useful error message.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only the first non-null redirect is honoured — subsequent handlers |
||
| } | ||
| } catch (Throwable $e) { | ||
| $this->logger->warning( | ||
| 'PreLogoutHandler ' . $handler::class . ' failed: ' . $e->getMessage() | ||
| ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Clear authentication | ||
| $this->registry->clearAuth(); | ||
|
|
||
|
|
@@ -453,6 +471,17 @@ public function performLogout(LogoutRequest $request): array | |
| // Ignore - theme will use system default | ||
| } | ||
|
|
||
| // Handler redirect takes priority over redirect_on_logout config | ||
| if ($postLogoutRedirect === null | ||
| && $request->reason === Horde_Auth::REASON_LOGOUT | ||
| && !empty($this->conf['auth']['redirect_on_logout'])) { | ||
| $postLogoutRedirect = $this->conf['auth']['redirect_on_logout']; | ||
| } | ||
|
|
||
| if ($postLogoutRedirect !== null) { | ||
| return ['redirect' => $postLogoutRedirect, 'reason' => $request->reason]; | ||
| } | ||
|
|
||
| // Default redirect to login page | ||
| $webroot = $this->registry->get('webroot', 'horde'); | ||
| $redirect = $webroot . '/auth/login?logout_reason=logout'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to reset the notification handler in this path, too?