X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FCore_person.php;h=c03d9621124fc6b6c3012bd4f1f2e764682ac736;hb=b32faa5954b497d89318489fabfdbaacf9da86d8;hp=a76d975fca74366eb7386e35efd6d7c1f2d8245d;hpb=d2cfff04c699ccae894eff96b59ebdc54ecb23e8;p=Pman.Core diff --git a/DataObjects/Core_person.php b/DataObjects/Core_person.php index a76d975f..c03d9621 100644 --- a/DataObjects/Core_person.php +++ b/DataObjects/Core_person.php @@ -235,6 +235,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject $sesPrefix = $this->sesPrefix(); + self::$authUser = false; $_SESSION[get_class($this)][$sesPrefix .'-auth'] = ""; return false; @@ -255,22 +256,26 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject $sesPrefix = $this->sesPrefix(); + if (self::$authUser) { + return self::$authUser; + } + + if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) { // in session... $a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']); - $u = DB_DataObject::factory($this->tableName()); + $u->autoJoin(); if ($a->id && $u->get($a->id)) { //&& strlen($u->passwd)) { - - return $u->verifyAuth(); // got authentication... - - + if ($u->verifyAuth()) { + self::$authUser = $u; + return true; + } } - unset($_SESSION[get_class($this)][$sesPrefix .'-auth']); unset($_SESSION[get_class($this)][$sesPrefix .'-timeout']); setcookie('Pman.timeout', -1, time() + (30*60), '/'); - + return false; } // http basic auth.. @@ -284,7 +289,10 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject && $u->checkPassword($_SERVER['PHP_AUTH_PW']) ) { - $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($u); + // logged in via http auth + // http auth will not need session... + //$_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($u); + self::$authUser = $u; return true; } //die("test init"); @@ -333,6 +341,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject "); if($member->find(true)){ $default_admin = DB_DataObject::factory($this->tableName()); + $default_admin->autoJoin(); if(!$default_admin->get($member->user_id)){ $default_admin = false; } @@ -341,6 +350,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject //var_dump($ff->Pman['local_autoauth']); var_dump($_SERVER); exit; $u = DB_DataObject::factory($this->tableName()); + $u->autoJoin(); $ff = HTML_FlexyFramework::get(); if ($auto_auth_allow && @@ -350,8 +360,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject $user = $default_admin ? $default_admin->toArray() : $u->toArray(); // if we request other URLS.. then we get auto logged in.. - - $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object) $user); + self::$authUser = $default_admin ? $default_admin : $u;; + //$_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object) $user); return true; } @@ -398,23 +408,15 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject //var_dump(array(get_class($this),$sesPrefix .'-auth')); - if (!empty($_SESSION[get_class($this)][$sesPrefix .'-auth'])) { - $a = unserialize($_SESSION[get_class($this)][$sesPrefix .'-auth']); - - $u = DB_DataObject::factory($this->tableName()); // allow extending this ... - $u->autoJoin(); - if ($u->get($a->id)) { /// && strlen($u->passwd)) { // should work out the pid .. really.. - + if (self::$authUser) { + + if (isset($_SESSION[get_class($this)][$sesPrefix .'-auth'])) { $_SESSION[get_class($this)][$sesPrefix .'-auth-timeout'] = time() + (30*60); // eg. 30 minutes setcookie('Pman.timeout', time() + (30*60), time() + (30*60), '/'); - - $user = clone ($u); - return clone($user); - } - unset($_SESSION[get_class($this)][$sesPrefix .'-auth']); - unset($_SESSION[get_class($this)][$sesPrefix .'-timeout']); - setcookie('Pman.timeout', -1, time() + (30*60), '/'); + // not really sure why it's cloned.. + return clone (self::$authUser); + } @@ -494,6 +496,12 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject //var_dump(array(get_class($this),$sesPrefix .'-auth')); $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize((object)$d); + + $pp = DB_DAtaObject::Factory($this->tableName()); + $pp->get($this->pid()); + $pp->autoJoin(); + + self::$authUser = $pp; // ensure it's written so that ajax calls can fetch it.. @@ -509,6 +517,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject $_SESSION[get_class($this)][$sesPrefix .'-auth'] = ""; + self::$authUser = false; + } function genPassKey ($t) { @@ -1411,7 +1421,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject return $sesPrefix; } - function loginPublic() + function loginPublic() // used where??? { $this->isAuth(); // force session start..