Re-read local database record if the remote auth did not supply principal_id

This commit is contained in:
Andrew McMillan 2010-06-21 10:56:01 +12:00
parent 28af315848
commit b296151724
2 changed files with 16 additions and 0 deletions

View File

@ -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 != '' ) {

View File

@ -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;