Commit a1120005ee021e42065871fef6b65911bbd92def

Authored by Michael Joseph
1 parent 827bbac7

fixed logout and improved logging


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1030 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/authentication/Authenticator.inc
@@ -28,7 +28,7 @@ class Authenticator { @@ -28,7 +28,7 @@ class Authenticator {
28 if ($this->checkPassword($sUserName, $sPassword)) { 28 if ($this->checkPassword($sUserName, $sPassword)) {
29 // retrieve the userID 29 // retrieve the userID
30 $iUserID = lookupID($default->owl_users_table, "username", "$sUserName"); 30 $iUserID = lookupID($default->owl_users_table, "username", "$sUserName");
31 - $default->log->info("Authenticator::login authenticated user, id=$iUserID"); 31 + $default->log->info("Authenticator::login authenticated ($sUserName, $sPassword), id=$iUserID");
32 if ($iUserID) { 32 if ($iUserID) {
33 // add this to the return array 33 // add this to the return array
34 $aUserDetails["userID"] = $iUserID; 34 $aUserDetails["userID"] = $iUserID;
@@ -37,11 +37,12 @@ class Authenticator { @@ -37,11 +37,12 @@ class Authenticator {
37 Session::removeStaleSessions($aUserDetails["userID"]); 37 Session::removeStaleSessions($aUserDetails["userID"]);
38 38
39 // Check if Maxsessions has been reached 39 // Check if Maxsessions has been reached
40 - // lookup maxsessions 40 + // FIXME: make this check work before production install
41 $maxSessions = lookupField($default->owl_users_table, "max_sessions", "id", $iUserID); 41 $maxSessions = lookupField($default->owl_users_table, "max_sessions", "id", $iUserID);
  42 + $default->log->debug("maxsessions=$maxSessions for userID=$iUserID");
42 $sql = $default->db; 43 $sql = $default->db;
43 if ($sql->query("SELECT * FROM $default->owl_sessions_table WHERE user_id = '".$aUserDetails["user_id"]."'")) { 44 if ($sql->query("SELECT * FROM $default->owl_sessions_table WHERE user_id = '".$aUserDetails["user_id"]."'")) {
44 - if ($sql->num_rows($sql) >= $maxSessions) { 45 + if ($sql->num_rows() >= $maxSessions) {
45 // return too many sessions status code 46 // return too many sessions status code
46 $aUserDetails["status"] = 3; 47 $aUserDetails["status"] = 3;
47 } else { 48 } else {
@@ -61,6 +62,7 @@ class Authenticator { @@ -61,6 +62,7 @@ class Authenticator {
61 $aUserDetails["status"] = 0; 62 $aUserDetails["status"] = 0;
62 } 63 }
63 } else { 64 } else {
  65 + $default->log->info("Authenticator::login login failed ($sUserName, $sPassword)");
64 // authentication failed 66 // authentication failed
65 $aUserDetails["status"] = 0; 67 $aUserDetails["status"] = 0;
66 } 68 }
@@ -73,9 +75,9 @@ class Authenticator { @@ -73,9 +75,9 @@ class Authenticator {
73 * @param int the ID of user logging out 75 * @param int the ID of user logging out
74 * @param string the user's sessionID 76 * @param string the user's sessionID
75 */ 77 */
76 - function logout($iUserID, $iSessionID) { 78 + function logout() {
77 // remove session from db 79 // remove session from db
78 - Session::destroy($iSessionID); 80 + Session::destroy();
79 } 81 }
80 82
81 /** 83 /**