Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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());
     }
 }