X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Pman%2FLogin.php;h=1ed580feda9888be247ecdc6eebfae02716ecc0e;hb=b703d81d86ae41e324e168d7187bbc741795a5fc;hp=f7327c9890ce3ab6fb6ad4a8c99796453b7aebb1;hpb=78c94a007dbbd22e1272f1be0697f0a68358eefe;p=Pman.Base diff --git a/Pman/Login.php b/Pman/Login.php index f7327c9..1ed580f 100644 --- a/Pman/Login.php +++ b/Pman/Login.php @@ -125,12 +125,21 @@ class Pman_Login extends Pman function switchUser($id) { + $tbl = empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable']; + $u = DB_DataObject::factory($tbl); + if (!$u->isAuth()) { + $this->err("not logged in"); + } + + $au = $u->getAuthUser(); + + // first check they have perms to do this.. - if (!$this->authUser || ($this->authUser->company_id_comptype != 'OWNER') || !$this->hasPerm('Core.Person', 'E')) { + if (!$au|| ($au->company_id_comptype != 'OWNER') || !$this->hasPerm('Core.Person', 'E')) { $this->jerr("User switching not permitted"); } - $old = clone($this->authUser); - $tbl = empty($ff->Pman['authTable']) ? 'Person' : $ff->Pman['authTable']; + $old = clone($au); + $u = DB_DataObject::factory($tbl); $u->get($id); if (!$u->active()) {