Commit 73a11d7db22f71da5f33297451da5144c6a5abbf

Authored by Jonathan Byrne
1 parent c1900489

KTS-1112

"after auto log-out, re-login as different user gives old url"

Fixed.
Added a check to redirect to the dashboard if a different user logs back in after a logout or a timeout.

Committed By: Jonathan Byrne
Reviewed By: Jalaloedien Abrahams

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7666 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 21 additions and 3 deletions
login.php
@@ -95,14 +95,24 @@ class LoginPageDispatcher extends KTDispatcher { @@ -95,14 +95,24 @@ class LoginPageDispatcher extends KTDispatcher {
95 #var_dump($oUser); 95 #var_dump($oUser);
96 #var_dump(PEAR::raiseError()); 96 #var_dump(PEAR::raiseError());
97 } 97 }
  98 + $iOldUserID = checkLastSessionUserID();
  99 +
  100 + //if the current person logging in isn't the same person who logged out or timed out
  101 + //then set the redirect to the dashboard and not the last page that was viewed.
  102 + if ($oUser->getId() != $iOldUserID['user_id'])
  103 + {
  104 + $_REQUEST['redirect'] = generateControllerLink('dashboard');
  105 +
  106 + }
  107 +
98 $session = new Session(); 108 $session = new Session();
99 $sessionID = $session->create($oUser); 109 $sessionID = $session->create($oUser);
100 if (PEAR::isError($sessionID)) { 110 if (PEAR::isError($sessionID)) {
101 return $sessionID; 111 return $sessionID;
102 } 112 }
103 -  
104 - $redirect = KTUtil::arrayGet($_REQUEST, 'redirect');  
105 - 113 +
  114 + $redirect = KTUtil::arrayGet($_REQUEST, 'redirect');
  115 +
106 // DEPRECATED initialise page-level authorisation array 116 // DEPRECATED initialise page-level authorisation array
107 $_SESSION["pageAccess"] = NULL; 117 $_SESSION["pageAccess"] = NULL;
108 118
@@ -322,6 +332,14 @@ class LoginPageDispatcher extends KTDispatcher { @@ -322,6 +332,14 @@ class LoginPageDispatcher extends KTDispatcher {
322 } 332 }
323 } 333 }
324 334
  335 +//FIXME Direct Database Access
  336 +//checkLastSessionUserID finds the last user to logout or timeout
  337 +function checkLastSessionUserID()
  338 +{
  339 + $sQuery = 'SELECT user_id FROM user_history ORDER BY id DESC LIMIT 1';
  340 + $res = DBUtil::getOneResult($sQuery);
  341 + return $res;
  342 +}
325 343
326 $dispatcher =& new LoginPageDispatcher(); 344 $dispatcher =& new LoginPageDispatcher();
327 $dispatcher->dispatch(); 345 $dispatcher->dispatch();