/**
  * In this method, actually create the user / account.
  *
  * NOTE: After this method is called, the $registrationFlow is DESTROYED, so you need to store all attributes
  * in your object as you need them.
  *
  * @param RegistrationFlow $registrationFlow
  * @return void
  */
 public function createUserAndAccount(RegistrationFlow $registrationFlow)
 {
     // Create the account
     $account = new Account();
     $account->setAccountIdentifier($registrationFlow->getEmail());
     $account->setCredentialsSource($registrationFlow->getEncryptedPassword());
     $account->setAuthenticationProviderName('Sandstorm.UserManagement:Login');
     // Assign preconfigured roles
     foreach ($this->rolesForNewUsers as $roleString) {
         $account->addRole(new Role($roleString));
     }
     // Create the user
     $user = new User();
     $name = new PersonName('', $registrationFlow->getAttributes()['firstName'], '', $registrationFlow->getAttributes()['lastName'], '', $registrationFlow->getEmail());
     $user->setName($name);
     // Assign them to each other and persist
     $this->getPartyService()->assignAccountToParty($account, $user);
     $this->getPartyRepository()->add($user);
     $this->accountRepository->add($account);
     $this->persistenceManager->whitelistObject($user);
     $this->persistenceManager->whitelistObject($user->getPreferences());
     $this->persistenceManager->whitelistObject($name);
     $this->persistenceManager->whitelistObject($account);
 }
 /**
  * Delete an electronic address action
  *
  * @param User $user
  * @param ElectronicAddress $electronicAddress
  * @return void
  */
 public function deleteElectronicAddressAction(User $user, ElectronicAddress $electronicAddress)
 {
     $user->removeElectronicAddress($electronicAddress);
     $this->userService->updateUser($user);
     $this->addFlashMessage('The electronic address "%s" (%s) has been deleted for "%s".', 'Electronic address removed', Message::SEVERITY_NOTICE, array(htmlspecialchars($electronicAddress->getIdentifier()), htmlspecialchars($electronicAddress->getType()), htmlspecialchars($user->getName())), 1412374678);
     $this->redirect('edit', null, null, array('user' => $user));
 }
 /**
  * Prepares a table row for output with data of the given User
  *
  * @param User $user The user
  * @return array
  */
 protected function getTableRowForUser(User $user)
 {
     $roleNames = array();
     $accountIdentifiers = array();
     foreach ($user->getAccounts() as $account) {
         /** @var Account $account */
         $authenticationProviderName = $account->getAuthenticationProviderName();
         if ($authenticationProviderName !== $this->userService->getDefaultAuthenticationProviderName()) {
             $authenticationProviderLabel = ' (' . (isset($this->authenticationProviderSettings[$authenticationProviderName]['label']) ? $this->authenticationProviderSettings[$authenticationProviderName]['label'] : $authenticationProviderName) . ')';
         } else {
             $authenticationProviderLabel = '';
         }
         $accountIdentifiers[] = $account->getAccountIdentifier() . $authenticationProviderLabel;
         foreach ($account->getRoles() as $role) {
             /** @var Role $role */
             $roleNames[] = $role->getIdentifier();
         }
     }
     return array($user->getName()->getFullName(), $user->getPrimaryElectronicAddress(), implode(', ', $accountIdentifiers), implode(', ', $roleNames), $user->isActive() ? 'yes' : 'no');
 }
 /**
  * @test
  */
 public function constructorInitializesPreferences()
 {
     $user = new User();
     $this->assertInstanceOf('TYPO3\\Neos\\Domain\\Model\\UserPreferences', $user->getPreferences());
 }
 /**
  * Creates a personal workspace for the given user's account if it does not exist already.
  *
  * @param User $user The new user to create a workspace for
  * @param Account $account The user's backend account
  * @throws IllegalObjectTypeException
  */
 protected function createPersonalWorkspace(User $user, Account $account)
 {
     $userWorkspaceName = UserUtility::getPersonalWorkspaceNameForUsername($account->getAccountIdentifier());
     $userWorkspace = $this->workspaceRepository->findByIdentifier($userWorkspaceName);
     if ($userWorkspace === null) {
         $liveWorkspace = $this->workspaceRepository->findByIdentifier('live');
         if (!$liveWorkspace instanceof Workspace) {
             $liveWorkspace = new Workspace('live');
             $liveWorkspace->setTitle('Live');
             $this->workspaceRepository->add($liveWorkspace);
         }
         $userWorkspace = new Workspace($userWorkspaceName, $liveWorkspace, $user);
         $userWorkspace->setTitle((string) $user->getName());
         $this->workspaceRepository->add($userWorkspace);
     }
 }
 /**
  * Deactivates the given user
  *
  * @param User $user The user to deactivate
  * @return void
  * @api
  */
 public function deactivateUser(User $user)
 {
     foreach ($user->getAccounts() as $account) {
         /** @var Account $account */
         $account->setExpirationDate($this->now);
         $this->accountRepository->update($account);
     }
     $this->emitUserDeactivated($user);
 }
 /**
  * Creates a temporary account
  *
  * @param string $accountIdentifier
  * @param string $password
  * @param string $firstName
  * @param string $lastName
  * @return Account
  */
 protected function createTemporaryAccount($accountIdentifier, $password, $firstName, $lastName)
 {
     if (strlen($firstName) === 0 && strlen($lastName) === 0) {
         $firstName = 'Santa';
         $lastName = 'Claus';
     }
     $user = new User();
     $user->setName(new PersonName('', $firstName, '', $lastName));
     $user->getPreferences()->set('context.workspace', 'user-' . $accountIdentifier);
     $this->partyRepository->add($user);
     $account = $this->accountFactory->createAccountWithPassword($accountIdentifier, $password, array('TYPO3.Neos:Editor'), 'Typo3BackendProvider');
     $account->setParty($user);
     $account->setExpirationDate(new \DateTime('+1 week'));
     $this->accountRepository->add($account);
 }
 /**
  * @test
  */
 public function constructorInitializesPreferences()
 {
     $user = new User();
     $this->assertInstanceOf(UserPreferences::class, $user->getPreferences());
 }
Beispiel #9
0
 /**
  * Constructs this Person
  *
  */
 public function __construct()
 {
     parent::__construct();
 }