From 8c385edb51c6bb2262ae35c60687a9c6d5df6a22 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Thu, 9 Jan 2014 23:18:20 +0000 Subject: [PATCH] Add bootstrap::signal function to connect to system-wide signals of interest Connect to logout signal and clear upgrader session on staff logout. --- bootstrap.php | 14 ++++++++++++++ include/class.auth.php | 1 + main.inc.php | 1 + 3 files changed, 16 insertions(+) diff --git a/bootstrap.php b/bootstrap.php index a82796ebd..9a66c5a07 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -48,6 +48,20 @@ class Bootstrap { $_SERVER['REMOTE_ADDR'] = ''; } + /* + * Glue to global signals we're interested in + */ + static function signals() { + + //Clear upgrader session on logout. + Signal::connect('auth.logout', function ($user, $data=null) { + if (!$user) return; + + if ($user instanceof Staff) + $_SESSION['ost_upgrader'] = null; + }); + } + function https() { return (isset($_SERVER['HTTPS']) diff --git a/include/class.auth.php b/include/class.auth.php index c7c36c8e8..054ccd941 100644 --- a/include/class.auth.php +++ b/include/class.auth.php @@ -303,6 +303,7 @@ abstract class StaffAuthenticationBackend extends AuthenticationBackend { $staff->getUserName(), $_SERVER['REMOTE_ADDR'])); //Debug. + Signal::send('auth.logout', $staff); } static function getUser() { diff --git a/main.inc.php b/main.inc.php index 7feb271e7..8c6d3d337 100644 --- a/main.inc.php +++ b/main.inc.php @@ -26,6 +26,7 @@ Bootstrap::defineTables(TABLE_PREFIX); Bootstrap::i18n_prep(); Bootstrap::loadCode(); Bootstrap::connect(); +Bootstrap::signals(); if(!($ost=osTicket::start()) || !($cfg = $ost->getConfig())) Bootstrap::croak('Unable to load config info from DB. Get tech support.'); -- GitLab