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); }
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); } } }
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); } } }
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); }
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); }
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(); }
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()); } }