Skip to content
Snippets Groups Projects
Commit 680d96d0 authored by Peter Rotich's avatar Peter Rotich
Browse files

Provide facility to get the auth backend for the authenticated user

Reafactor logOut to use the piggyback on auth backend
parent 4d1eb53c
No related branches found
No related tags found
No related merge requests found
......@@ -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]",
......
......@@ -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() {
......
......@@ -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*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment