private function assertKuser()
 {
     // check copied values
     $this->assertEquals($this->systemUser->getFirstName(), $this->kuser->getFirstName(), 'first_name for ' . $this->getParams());
     $this->assertEquals($this->systemUser->getLastName(), $this->kuser->getLastName(), 'last_name for ' . $this->getParams());
     $this->assertEquals($this->systemUser->getEmail(), $this->kuser->getPuserId(), 'puserid for ' . $this->getParams());
     $this->assertEquals($this->adminConsolePartnerId, $this->kuser->getPartnerId(), 'partner_id for ' . $this->getParams());
     $this->assertEquals($this->systemUser->getEmail(), $this->kuser->getEmail(), 'email for ' . $this->getParams());
     $this->assertEquals($this->systemUser->getName(), $this->kuser->getScreenName(), 'screen_name for ' . $this->getParams());
     $this->assertEquals($this->systemUser->getName(), $this->kuser->getFullName(), 'full_name for ' . $this->getParams());
     if ($this->systemUser->getStatus == systemUser::SYSTEM_USER_ACTIVE) {
         $this->assertEquals(KuserStatus::ACTIVE, $this->kuser->getStatus(), 'status ' . $this->getParams());
     } else {
         $this->assertEquals(KuserStatus::BLOCKED, $this->kuser->getStatus(), 'status ' . $this->getParams());
     }
     $this->assertEquals($this->systemUser->getDeletedAt(), $this->kuser->getDeletedAt(), 'deleted_at ' . $this->getParams());
     $partnerData = unserialize($this->kuser->getPartnerData());
     var_dump($partnerData);
     $this->assertTrue(get_class($partnerData) === 'Kaltura_AdminConsoleUserPartnerData', 'PartnerData is not of type Kaltura_AdminConsoleUserPartnerData');
     $this->assertEquals($this->systemUser->getIsPrimary(), $partnerData->isPrimary, 'is_primary ' . $this->getParams());
     $this->assertEquals($this->systemUser->getRole(), $partnerData->role, 'role ' . $this->getParams());
     // check new values
     $this->assertEquals(true, $this->kuser->getIsAdmin(), 'is_admin for ' . $this->getParams());
     $this->assertEquals($this->kuser->getLoginDataId(), $this->loginData->getId());
 }
 private function assertKuser()
 {
     // check copied values
     $this->assertEquals($this->adminKuser->getFullName(), $this->kuser->getFullName(), 'full_name for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getIcon(), $this->kuser->getIcon(), 'icon for ' . $this->getParams());
     $this->assertEquals('__ADMIN__' . $this->adminKuser->getId(), $this->kuser->getPuserId(), 'puserid for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPartnerId(), $this->kuser->getPartnerId(), 'partner_id for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getPicture(), $this->kuser->getPicture(), 'picture for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getEmail(), $this->kuser->getEmail(), 'email for ' . $this->getParams());
     $this->assertEquals($this->adminKuser->getScreenName(), $this->kuser->getScreenName(), 'screen_name for ' . $this->getParams());
     // check new values
     $this->assertEquals(true, $this->kuser->getIsAdmin(), 'is_admin for ' . $this->getParams());
     $this->assertEquals($this->kuser->getLoginDataId(), $this->loginData->getId());
 }
예제 #3
0
 /**
  * Adds a new kuser and user_login_data records as needed
  * @param kuser $user
  * @param string $password
  * @param bool $checkPasswordStructure
  * @throws kUserException::USER_NOT_FOUND
  * @throws kUserException::USER_ALREADY_EXISTS
  * @throws kUserException::INVALID_EMAIL
  * @throws kUserException::INVALID_PARTNER
  * @throws kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED
  * @throws kUserException::LOGIN_ID_ALREADY_USED
  * @throws kUserException::PASSWORD_STRUCTURE_INVALID
  * @throws kPermissionException::ROLE_ID_MISSING
  * @throws kPermissionException::ONLY_ONE_ROLE_PER_USER_ALLOWED
  */
 public static function addUser(kuser $user, $password = null, $checkPasswordStructure = true, $sendEmail = null)
 {
     if (!$user->getPuserId()) {
         throw new kUserException('', kUserException::USER_ID_MISSING);
     }
     // check if user with the same partner and puserId already exists
     $existingUser = kuserPeer::getKuserByPartnerAndUid($user->getPartnerId(), $user->getPuserId());
     if ($existingUser) {
         throw new kUserException('', kUserException::USER_ALREADY_EXISTS);
     }
     // check if roles are valid - may throw exceptions
     if (!$user->getRoleIds() && $user->getIsAdmin()) {
         // assign default role according to user type admin / normal
         $userRoleId = $user->getPartner()->getAdminSessionRoleId();
         $user->setRoleIds($userRoleId);
     }
     UserRolePeer::testValidRolesForUser($user->getRoleIds(), $user->getPartnerId());
     if ($user->getScreenName() === null) {
         $user->setScreenName($user->getPuserId());
     }
     if ($user->getFullName() === null) {
         $user->setFirstName($user->getPuserId());
     }
     if (is_null($user->getStatus())) {
         $user->setStatus(KuserStatus::ACTIVE);
     }
     // if password is set, user should be able to login to the system - add a user_login_data record
     if ($password || $user->getIsAdmin()) {
         // throws an action on error
         $user->enableLogin($user->getEmail(), $password, $checkPasswordStructure, $sendEmail);
     }
     $user->save();
     return $user;
 }
예제 #4
0
 public function isValid($partner_id, $puser_id, $type = false)
 {
     if (!$this->valid_string) {
         return self::INVALID_STR;
     }
     if (!$this->matchPartner($partner_id)) {
         return self::INVALID_PARTNER;
     }
     if (!$this->matchUser($puser_id)) {
         return self::INVALID_USER;
     }
     if ($type !== false) {
         // do not check ks type
         if (!$this->type == $type) {
             return self::INVALID_TYPE;
         }
     }
     if ($this->expired()) {
         return self::EXPIRED;
     }
     if (!$this->isUserIPAllowed()) {
         return self::EXCEEDED_RESTRICTED_IP;
     }
     if ($this->original_str && $partner_id != Partner::BATCH_PARTNER_ID && !$this->isWidgetSession() && $this->isKSInvalidated() !== false) {
         $criteria = new Criteria();
         $ksCriterion = $criteria->getNewCriterion(invalidSessionPeer::TYPE, invalidSession::INVALID_SESSION_TYPE_KS);
         $ksCriterion->addAnd($criteria->getNewCriterion(invalidSessionPeer::KS, $this->getHash()));
         $sessionId = $this->getSessionIdHash();
         if ($sessionId) {
             $invalidSession = $criteria->getNewCriterion(invalidSessionPeer::KS, $sessionId);
             $invalidSession->addAnd($criteria->getNewCriterion(invalidSessionPeer::TYPE, invalidSession::INVALID_SESSION_TYPE_SESSION_ID));
             $ksCriterion->addOr($invalidSession);
         }
         $criteria->add($ksCriterion);
         $dbKs = invalidSessionPeer::doSelectOne($criteria);
         if ($dbKs) {
             $currentActionLimit = $dbKs->getActionsLimit();
             if (is_null($currentActionLimit)) {
                 return self::LOGOUT;
             } elseif ($currentActionLimit <= 0) {
                 return self::EXCEEDED_ACTIONS_LIMIT;
             }
             $dbKs->setActionsLimit($currentActionLimit - 1);
             $dbKs->save();
         } else {
             $limit = $this->isSetLimitAction();
             if ($limit) {
                 invalidSessionPeer::actionsLimitKs($this, $limit - 1);
             }
         }
     }
     // creates the kuser
     if ($partner_id != Partner::BATCH_PARTNER_ID && PermissionPeer::isValidForPartner(PermissionName::FEATURE_END_USER_REPORTS, $partner_id)) {
         $this->kuser = kuserPeer::createKuserForPartner($partner_id, $puser_id);
         if (!$puser_id && $this->kuser->getScreenName() != 'Unknown') {
             $this->kuser->setScreenName('Unknown');
             $this->kuser->save();
         }
     }
     return self::OK;
 }