示例#1
0
 /**
  * Return (or create, assuming no external auth backend) a user based on
  * a provided openid identity
  * 
  * @param string $identity
  * 
  * @return TBGUser 
  */
 public static function getByOpenID($identity)
 {
     $user = null;
     if ($user_id = TBGOpenIdAccountsTable::getTable()->getUserIDfromIdentity($identity)) {
         $user = TBGContext::factory()->TBGUser($user_id);
     } elseif (!TBGSettings::isUsingExternalAuthenticationBackend() && TBGSettings::getOpenIDStatus() == 'all') {
         $user = new TBGUser();
         $user->setPassword(TBGUser::createPassword());
         $user->setUsername(TBGUser::createPassword() . TBGUser::createPassword());
         $user->setOpenIdLocked();
         $user->setActivated();
         $user->setEnabled();
         $user->setValidated();
         $user->save();
     }
     return $user;
 }