Пример #1
0
 public function Synchronize(AuthenticatedUser $user, $insertOnly = false)
 {
     if ($this->UserExists($user->UserName(), $user->Email())) {
         if ($insertOnly) {
             return;
         }
         $encryptedPassword = $this->_passwordEncryption->EncryptPassword($user->Password());
         $command = new UpdateUserFromLdapCommand($user->UserName(), $user->Email(), $user->FirstName(), $user->LastName(), $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $user->Phone(), $user->Organization(), $user->Title());
         ServiceLocator::GetDatabase()->Execute($command);
     } else {
         $additionalFields = array('phone' => $user->Phone(), 'organization' => $user->Organization(), 'position' => $user->Title());
         $this->Register($user->UserName(), $user->Email(), $user->FirstName(), $user->LastName(), $user->Password(), $user->TimezoneName(), $user->LanguageCode(), Pages::DEFAULT_HOMEPAGE_ID, $additionalFields);
     }
 }
Пример #2
0
 public function Synchronize(AuthenticatedUser $user, $insertOnly = false)
 {
     if ($this->UserExists($user->UserName(), $user->Email())) {
         if ($insertOnly) {
             return;
         }
         $encryptedPassword = $this->_passwordEncryption->EncryptPassword($user->Password());
         $command = new UpdateUserFromLdapCommand($user->UserName(), $user->Email(), $user->FirstName(), $user->LastName(), $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $user->Phone(), $user->Organization(), $user->Title());
         ServiceLocator::GetDatabase()->Execute($command);
         if ($user->GetGroups() != null) {
             $updatedUser = $this->_userRepository->LoadByUsername($user->Username());
             $updatedUser->ChangeGroups($user->GetGroups());
             $this->_userRepository->Update($updatedUser);
         }
     } else {
         $defaultHomePageId = Configuration::Instance()->GetKey(ConfigKeys::DEFAULT_HOMEPAGE, new IntConverter());
         $additionalFields = array('phone' => $user->Phone(), 'organization' => $user->Organization(), 'position' => $user->Title());
         $this->Register($user->UserName(), $user->Email(), $user->FirstName(), $user->LastName(), $user->Password(), $user->TimezoneName(), $user->LanguageCode(), empty($defaultHomePageId) ? Pages::DEFAULT_HOMEPAGE_ID : $defaultHomePageId, $additionalFields, array(), $user->GetGroups());
     }
 }
Пример #3
0
 public function testAuthenticatedUserReturnsNullsForAllBlankValues()
 {
     $username = '******';
     $email = 'em';
     $fname = '';
     $lname = ' ';
     $phone = '   ';
     $inst = 'or';
     $title = 'title';
     $langCode = 'en_US';
     $timezone = 'UTC';
     $user = new AuthenticatedUser($username, $email, $fname, $lname, 'password', $langCode, $timezone, $phone, $inst, $title);
     $this->assertNull($user->FirstName(), "needs to be null to make sure we do not clear values in the database");
     $this->assertNull($user->LastName(), "needs to be null to make sure we do not clear values in the database");
     $this->assertNull($user->Phone(), "needs to be null to make sure we do not clear values in the database");
     $this->assertEquals($email, $user->Email());
 }