diff --git a/include/class.auth.php b/include/class.auth.php index 8746c5b23d21f13f5036497611fbcd7e559cf381..9913c43e83cc53ee49ef7ea747a1c4985686340b 100644 --- a/include/class.auth.php +++ b/include/class.auth.php @@ -11,8 +11,11 @@ abstract class AuthenticatedUser { abstract function getId(); abstract function getUsername(); abstract function getRole(); - abstract function logOut(); + //Backend used to authenticate the user + abstract function getAuthBackend(); + + //Authentication key function setAuthKey($key) { $this->authkey = $key; } @@ -20,6 +23,15 @@ abstract class AuthenticatedUser { function getAuthKey() { return $this->authkey; } + + // logOut the user + function logOut() { + + if ($bk = $this->getAuthBackend()) + return $bk->signOut($this); + + return false; + } } interface AuthDirectorySearch { @@ -293,12 +305,15 @@ abstract class StaffAuthenticationBackend extends AuthenticationBackend { return true; } + /* Base signOut + * + * Backend should extend the signout and perform any additional signout + * it requires. + */ + static function signOut($staff) { global $ost; - list($id, $auth) = explode(':', $_SESSION['_auth']['staff']['key']); - //TODO: Lookup the backed and request logout.. - $_SESSION['_auth']['staff'] = array(); $ost->logDebug('Staff logout', sprintf("%s logged out [%s]", @@ -395,9 +410,6 @@ abstract class UserAuthenticationBackend extends AuthenticationBackend { static function signOut($user) { global $ost; - list($id, $auth) = explode(':', $_SESSION['_auth']['user']['key']); - //TODO: Lookup the backed and request logout.. - $_SESSION['_auth']['user'] = array(); $ost->logDebug('User logout', sprintf("%s logged out [%s]", diff --git a/include/class.client.php b/include/class.client.php index 0fa312b5e50835828bb4c40ef8833cbff0e2558e..93aa1b07f0b978f6a11fdfa64eb25b3b62de7808 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -179,8 +179,9 @@ class EndUser extends AuthenticatedUser { return $this->isOwner() ? 'owner' : 'collaborator'; } - function logOut() { - return UserAuthenticationBackend::signOut($this); + function getAuthBackend() { + list($authkey,) = explode(':', $this->getAuthKey()); + return UserAuthenticationBackend::getBackend($authkey); } function getTicketStats() { diff --git a/include/class.staff.php b/include/class.staff.php index cf6238fcceed445e810562885875e91fcd027957..e353c5cd908c6ce9a1e316f03b3098fe3cc94556 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -105,8 +105,9 @@ class Staff extends AuthenticatedUser { return 'staff'; } - function logOut() { - return StaffAuthenticationBackend::signOut($this); + function getAuthBackend() { + list($authkey, ) = explode(':', $this->getAuthKey()); + return StaffAuthenticationBackend::getBackend($authkey); } /*compares user password*/