diff --git a/inc/DAViCalSession.php b/inc/DAViCalSession.php index 04b6d5d2..c7635fa5 100644 --- a/inc/DAViCalSession.php +++ b/inc/DAViCalSession.php @@ -65,6 +65,14 @@ class DAViCalSession extends Session * @param object $u The user+session object we (probably) read from the database. */ function AssignSessionDetails( $u ) { + if ( !isset($u->principal_id) ) { + // If they don't have a principal_id set then we should re-read from our local database + $qry = new AwlQuery('SELECT * FROM dav_principal WHERE username = :username', array(':username' => $u->username) ); + if ( $qry->Exec() && $qry->rows() == 1 ) { + $u = $qry->Fetch(); + } + } + parent::AssignSessionDetails( $u ); $this->GetRoles(); if ( function_exists('awl_set_locale') && isset($this->locale) && $this->locale != '' ) { diff --git a/inc/HTTPAuthSession.php b/inc/HTTPAuthSession.php index 344530ad..6e8a998c 100644 --- a/inc/HTTPAuthSession.php +++ b/inc/HTTPAuthSession.php @@ -274,6 +274,14 @@ class HTTPAuthSession { * @param object $u The user+session object we (probably) read from the database. */ function AssignSessionDetails( $u ) { + if ( !isset($u->principal_id) ) { + // If they don't have a principal_id set then we should re-read from our local database + $qry = new AwlQuery('SELECT * FROM dav_principal WHERE username = :username', array(':username' => $u->username) ); + if ( $qry->Exec() && $qry->rows() == 1 ) { + $u = $qry->Fetch(); + } + } + // Assign each field in the selected record to the object foreach( $u AS $k => $v ) { $this->{$k} = $v;