Ejemplo n.º 1
0
 public function Activate($activationCode)
 {
     $userId = $this->activationRepository->FindUserIdByCode($activationCode);
     $this->activationRepository->DeleteActivation($activationCode);
     if ($userId != null) {
         $user = $this->userRepository->LoadById($userId);
         $user->Activate();
         $this->userRepository->Update($user);
         return new ActivationResult(true, $user);
     }
     return new ActivationResult(false);
 }
Ejemplo n.º 2
0
 public function PageLoad()
 {
     if ($this->page->ResettingPassword()) {
         $this->LoadValidators();
         if ($this->page->IsValid()) {
             $user = $this->GetUser();
             $password = $this->page->GetPassword();
             $encrypted = $this->passwordEncryption->EncryptPassword($password);
             $user->ChangePassword($encrypted->EncryptedPassword(), $encrypted->Salt());
             $this->userRepository->Update($user);
             $this->page->ShowResetPasswordSuccess(true);
         }
     }
 }
Ejemplo n.º 3
0
 public function PageLoad()
 {
     $this->page->SetAllowedActions(PluginManager::Instance()->LoadAuthentication());
     if ($this->page->ResettingPassword()) {
         $this->LoadValidators();
         if ($this->page->IsValid()) {
             $user = $this->GetUser();
             $password = $this->page->GetPassword();
             $encrypted = $this->passwordEncryption->EncryptPassword($password);
             $user->ChangePassword($encrypted->EncryptedPassword(), $encrypted->Salt());
             $this->userRepository->Update($user);
             $this->page->ShowResetPasswordSuccess(true);
         }
     }
 }
Ejemplo n.º 4
0
 public function DisableSubscription()
 {
     $userId = ServiceLocator::GetServer()->GetUserSession()->UserId;
     Log::Debug('Disabling calendar subscription for userId: %s', $userId);
     $user = $this->userRepository->LoadById($userId);
     $user->DisableSubscription();
     $this->userRepository->Update($user);
 }
Ejemplo n.º 5
0
 public function UpdateUser($userId, $username, $email, $firstName, $lastName, $timezone, $extraAttributes)
 {
     $attributes = new UserAttribute($extraAttributes);
     $user = $this->userRepository->LoadById($userId);
     $user->ChangeName($firstName, $lastName);
     $user->ChangeEmailAddress($email);
     $user->ChangeUsername($username);
     $user->ChangeTimezone($timezone);
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $this->userRepository->Update($user);
 }
Ejemplo n.º 6
0
 public function Login($username, $loginContext)
 {
     Log::Debug('Logging in with user: %s', $username);
     $user = $this->userRepository->LoadByUsername($username);
     if ($user->StatusId() == AccountStatus::ACTIVE) {
         $loginData = $loginContext->GetData();
         $loginTime = LoginTime::Now();
         $language = $user->Language();
         if (!empty($loginData->Language)) {
             $language = $loginData->Language;
         }
         $user->Login($loginTime, $language);
         $this->userRepository->Update($user);
         return $this->GetUserSession($user, $loginTime);
     }
     return new NullUserSession();
 }
Ejemplo n.º 7
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());
     }
 }