Don't write the user record every time a user connects via external auth.

This commit is contained in:
Andrew McMillan 2009-09-26 21:48:58 +12:00
parent 11951a09cd
commit 185aeb06bb

View File

@ -99,8 +99,27 @@ function UpdateUserFromExternal( &$usr ) {
}
$qry = new PgQuery("SELECT * FROM usr WHERE user_no = $usr->user_no;" );
if ( $qry->Exec('Login',__LINE,__FILE__) && $qry->rows == 1 )
if ( $qry->Exec('Login',__LINE,__FILE__) && $qry->rows == 1 ) {
$type = "UPDATE";
if ( $old = $qry->Fetch() ) {
$changes = false;
foreach( $usr AS $k => $v ) {
if ( $old->{$k} != $v ) {
$changes = true;
dbg_error_log("Login","User '%s' field '%s' changed from '%s' to '%s'", $usr->username, $k, $old->{$k}, $v );
break;
}
}
if ( !$changes ) {
dbg_error_log("Login","No changes to user record for '%s' - leaving as-is.", $usr->username );
if ( isset($usr->active) && $usr->active == 'f' ) return false;
return; // Normal case, if there are no changes
}
else {
dbg_error_log("Login","Changes to user record for '%s' - updating.", $usr->username );
}
}
}
else
$type = "INSERT";