private function assertLoginData()
 {
     // check copied values
     $this->assertEquals($this->adminKuser->getEmail(), $this->loginData->getLoginEmail(), 'login_email for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPartnerId(), $this->loginData->getConfigPartnerId(), 'config_partner_id for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getSalt(), $this->loginData->getSalt(), 'salt for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getSha1Password(), $this->loginData->getSha1Password(), 'sha1_password for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getLoginAttempts(), $this->loginData->getLoginAttempts(), 'login_attempts for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getLoginBlockPeriod(), $this->loginData->getLoginBlockPeriod(), 'login_block_period for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getMaxLoginAttempts(), $this->loginData->getMaxLoginAttempts(), 'max_login_attempts for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getNumPrevPassToKeep(), $this->loginData->getNumPrevPassToKeep(), 'num_prev_pass_to_keep for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPassReplaceFreq(), $this->loginData->getPassReplaceFreq(), 'pass_replace_freq for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPasswordHashKey(), $this->loginData->getPasswordHashKey(), 'password_hash_key for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPasswordUpdatedAt(), $this->loginData->getPasswordUpdatedAt(), 'password_updated_at for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPreviousPasswords(), $this->loginData->getPreviousPasswords(), 'previous_passwords for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getLoginBlockedUntil(), $this->loginData->getLoginBlockedUntil(), 'login_blocked_until for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getFullName(), $this->loginData->getFullName(), 'full_name for ' . $this->getParams());
     // check new values
     $this->assertEquals($this->adminKuser->getPartnerId(), $this->loginData->getLastLoginPartnerId(), 'last_login_partner_id for ' . $this->getParams());
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      UserLoginData $value A UserLoginData object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(UserLoginData $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) {
             self::$instances[$key] = $obj;
             kMemoryManager::registerPeer('UserLoginDataPeer');
         }
     }
 }
Example #3
0
 /**
  * Tests UserLoginData->isPassHashKeyValid()
  */
 public function testIsPassHashKeyValid()
 {
     // TODO Auto-generated UserLoginDataTest->testIsPassHashKeyValid()
     $this->markTestIncomplete("isPassHashKeyValid test not implemented");
     $this->UserLoginData->isPassHashKeyValid();
 }
    $lastUser = 0;
}
$users = getUsers($lastUser, $userLimitEachLoop);
while (count($users)) {
    foreach ($users as $user) {
        if (file_exists($stopFile)) {
            die('STOP FILE CREATED');
        }
        $lastUser = $user->getId();
        KalturaLog::log('-- admin kuser id ' . $lastUser);
        if ($user->getPartnerId() == PartnerPeer::GLOBAL_PARTNER) {
            KalturaLog::log('Skipping partner 0');
            continue;
        }
        $new_kuser = new kuser();
        $new_login_data = new UserLoginData();
        $partner = PartnerPeer::retrieveByPK($user->getPartnerId());
        if (!$partner) {
            KalturaLog::alert('!!! ERROR - Partner ID [' . $user->getPartnerId() . '] not found on DB but set for admin user id [' . $lastUser . '] !!!');
            echo '!!! ERROR - Partner ID [' . $user->getPartnerId() . '] not found on DB but set for admin user id [' . $lastUser . '] !!!';
            continue;
        }
        list($firstName, $lastName) = kString::nameSplit($user->getFullName());
        $c = new Criteria();
        $c->addAnd(UserLoginDataPeer::LOGIN_EMAIL, $user->getEmail());
        $existing_login_data = UserLoginDataPeer::doSelectOne($c);
        if ($existing_login_data) {
            if ($user->getPartnerId() === $existing_login_data->getConfigPartnerId()) {
                $checkKuser = kuserPeer::getByLoginDataAndPartner($existing_login_data->getId(), $user->getPartnerId());
                if ($checkKuser && $checkKuser->getIsAdmin()) {
                    KalturaLog::notice('!!! NOTICE - Existing ADMIN login data found with id [' . $existing_login_data->getId() . '] partner [' . $existing_login_data->getConfigPartnerId() . '] - skipping user id [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] since this was probably caused by a bug');
Example #5
0
 /**
  * Adds a new user login data record
  * @param unknown_type $loginEmail
  * @param unknown_type $password
  * @param unknown_type $partnerId
  * @param unknown_type $firstName
  * @param unknown_type $lastName
  * @param bool $checkPasswordStructure backward compatibility - some extensions are registering a partner and setting its first password without checking its structure
  *
  * @throws kUserException::INVALID_EMAIL
  * @throws kUserException::INVALID_PARTNER
  * @throws kUserException::PASSWORD_STRUCTURE_INVALID
  * @throws kUserException::LOGIN_ID_ALREADY_USED
  * @throws kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED
  */
 public static function addLoginData($loginEmail, $password, $partnerId, $firstName, $lastName, $isAdminUser, $checkPasswordStructure = true, &$alreadyExisted = null)
 {
     if (!kString::isEmailString($loginEmail)) {
         throw new kUserException('', kUserException::INVALID_EMAIL);
     }
     $partner = partnerPeer::retrieveByPK($partnerId);
     if (!$partner) {
         throw new kUserException('', kUserException::INVALID_PARTNER);
     }
     if ($isAdminUser) {
         $userQuota = $partner->getAdminLoginUsersQuota();
         $adminLoginUsersNum = $partner->getAdminLoginUsersNumber();
         // check if login users quota exceeded - value -1 means unlimited
         if ($adminLoginUsersNum && (is_null($userQuota) || $userQuota != -1 && $userQuota <= $adminLoginUsersNum)) {
             throw new kUserException('', kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED);
         }
     }
     $existingData = self::getByEmail($loginEmail);
     if (!$existingData) {
         if ($checkPasswordStructure && !UserLoginDataPeer::isPasswordStructureValid($password)) {
             throw new kUserException('', kUserException::PASSWORD_STRUCTURE_INVALID);
         }
         // create a new login data record
         $loginData = new UserLoginData();
         $loginData->setConfigPartnerId($partnerId);
         $loginData->setLoginEmail($loginEmail);
         $loginData->setFirstName($firstName);
         $loginData->setLastName($lastName);
         $loginData->setPassword($password);
         $loginData->setLoginAttempts(0);
         $loginData->setLoginBlockedUntil(null);
         $loginData->resetPreviousPasswords();
         $loginData->save();
         // now $loginData has an id and hash key can be generated
         $hashKey = $loginData->newPassHashKey();
         $loginData->setPasswordHashKey($hashKey);
         $loginData->save();
         $alreadyExisted = false;
         return $loginData;
     } else {
         // add existing login data if password is valid
         $existingKuser = kuserPeer::getByLoginDataAndPartner($existingData->getId(), $partnerId);
         if ($existingKuser) {
             // partner already has a user with the same login data
             throw new kUserException('', kUserException::LOGIN_ID_ALREADY_USED);
         }
         KalturaLog::debug('Existing login data with the same email & password exists - returning id [' . $existingData->getId() . ']');
         $alreadyExisted = true;
         if ($isAdminUser && !$existingData->isLastLoginPartnerIdSet()) {
             $existingData->setLastLoginPartnerId($partnerId);
             $existingData->save();
         }
         return $existingData;
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      UserLoginData $value A UserLoginData object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(UserLoginData $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
     die('STOP FILE CREATED');
 }
 $lastUser = $user->getId();
 KalturaLog::log('-- system user id ' . $lastUser);
 // check for existing kusers for this admin_kuser
 $c = new Criteria();
 $c->addAnd(kuserPeer::PUSER_ID, $user->getEmail(), Criteria::EQUAL);
 $c->addAnd(kuserPeer::PARTNER_ID, $admin_console_partner_id, Criteria::EQUAL);
 $existing_kuser = kuserPeer::doSelectOne($c);
 if ($existing_kuser) {
     $new_kuser = $existing_kuser;
     // in case this script is executed more than once
 } else {
     $new_kuser = new kuser();
 }
 $new_login_data = new UserLoginData();
 $new_kuser->setEmail($user->getEmail());
 $new_kuser->setCreatedAt($user->getCreatedAt());
 $new_kuser->setUpdatedAt($user->getUpdatedAt());
 $new_kuser->setScreenName($user->getFirstName() . ' ' . $user->getLastName());
 $new_kuser->setPartnerId($admin_console_partner_id);
 $new_kuser->setFirstName($user->getFirstName());
 $new_kuser->setLastName($user->getLastName());
 if ($user->getStatus() == SystemUser::SYSTEM_USER_ACTIVE) {
     $new_kuser->setStatus(KuserStatus::ACTIVE);
 } else {
     $new_kuser->setStatus(KuserStatus::BLOCKED);
 }
 $new_kuser->setPuserId($user->getEmail());
 $new_kuser->setIsAdmin(true);
 $partnerData = new Kaltura_AdminConsoleUserPartnerData();
Example #8
0
         $newTempEmail = 'kuser_' . $user->getId() . '_' . $user->getEmail();
         $msg = 'NOTICE - kuser [' . $lastUser . '] of partner [' . $user->getPartnerId() . '] is set with invalid email [' . $user->getEmail() . '] - setting kusers login email to [' . $newTempEmail . ']!';
         KalturaLog::notice($msg);
     }
     // user can login - add a user_login_data record
     $existingLoginData = UserLoginDataPeer::getByEmail($newTempEmail);
     if ($existingLoginData) {
         $msg = 'NOTICE - login data for the same email [' . $newTempEmail . '] partner id [' . $existingLoginData->getConfigPartnerId() . '] already exists - setting kusers login email to';
         $newTempEmail = 'kuser_' . $user->getId() . '_' . $user->getEmail();
         while ($temp = UserLoginDataPeer::getByEmail($newTempEmail)) {
             $newTempEmail = '_' . $newTempEmail;
         }
         $msg .= ' [' . $newTempEmail . ']!';
         KalturaLog::notice($msg);
     }
     $new_login_data = new UserLoginData();
     $new_login_data->setConfigPartnerId($user->getPartnerId());
     $new_login_data->setLoginEmail($newTempEmail);
     $new_login_data->setFirstName($user->getFirstName());
     $new_login_data->setLastName($user->getLastName());
     $new_login_data->setSalt($user->getSalt());
     $new_login_data->setSha1Password($user->getSha1Password());
     $new_login_data->setCreatedAt($user->getCreatedAt());
     $new_login_data->setUpdatedAt($user->getUpdatedAt());
 }
 if (!$dryRun) {
     if ($new_login_data) {
         KalturaLog::log('Saving new user_login_data with the following parameters: ' . PHP_EOL);
         KalturaLog::log(print_r($new_login_data, true));
         $new_login_data->save();
         // save