diff --git a/login.php b/login.php index 9e2afce..11ecee4 100644 --- a/login.php +++ b/login.php @@ -95,14 +95,24 @@ class LoginPageDispatcher extends KTDispatcher { #var_dump($oUser); #var_dump(PEAR::raiseError()); } + $iOldUserID = checkLastSessionUserID(); + + //if the current person logging in isn't the same person who logged out or timed out + //then set the redirect to the dashboard and not the last page that was viewed. + if ($oUser->getId() != $iOldUserID['user_id']) + { + $_REQUEST['redirect'] = generateControllerLink('dashboard'); + + } + $session = new Session(); $sessionID = $session->create($oUser); if (PEAR::isError($sessionID)) { return $sessionID; } - - $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); - + + $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); + // DEPRECATED initialise page-level authorisation array $_SESSION["pageAccess"] = NULL; @@ -322,6 +332,14 @@ class LoginPageDispatcher extends KTDispatcher { } } +//FIXME Direct Database Access +//checkLastSessionUserID finds the last user to logout or timeout +function checkLastSessionUserID() +{ + $sQuery = 'SELECT user_id FROM user_history ORDER BY id DESC LIMIT 1'; + $res = DBUtil::getOneResult($sQuery); + return $res; +} $dispatcher =& new LoginPageDispatcher(); $dispatcher->dispatch();