public function setUp()
 {
     parent::setUp();
     $this->persistedUsernamePasswordProvider = new PersistedUsernamePasswordProvider('myTestProvider');
     $this->accountFactory = new \TYPO3\Flow\Security\AccountFactory();
     $this->accountRepository = new \TYPO3\Flow\Security\AccountRepository();
     $this->authenticationToken = $this->getAccessibleMock(\TYPO3\Flow\Security\Authentication\Token\UsernamePassword::class, array('dummy'));
     $account = $this->accountFactory->createAccountWithPassword('username', 'password', array(), 'myTestProvider');
     $this->accountRepository->add($account);
     $this->persistenceManager->persistAll();
 }
コード例 #2
0
ファイル: UserFactory.php プロジェクト: e-webking/lostfound
 /**
  * Creates a User with the given information
  *
  * The User is not added to the repository, the caller has to add the
  * User account to the AccountRepository and the User to the
  * PartyRepository to persist it.
  *
  * @param string $username The username of the user to be created.
  * @param string $password Password of the user to be created
  * @param string $firstName First name of the user to be created
  * @param string $lastName Last name of the user to be created
  * @param array $roleIdentifiers A list of role identifiers to assign
  * @return TYPO3\Party\Domain\Model\Person The created user instance
  */
 public function create($username, $password, $firstName, $lastName, array $roleIdentifiers = NULL)
 {
     $user = new \Incvisio\LostFound\Domain\Model\User();
     $name = new \TYPO3\Party\Domain\Model\PersonName('', $firstName, '', $lastName, '', $username);
     $user->setName($name);
     if ($roleIdentifiers === NULL || $roleIdentifiers === array()) {
         $roleIdentifiers = array(self::BASIC_USER_GROUP);
     }
     $account = $this->accountFactory->createAccountWithPassword($username, $password, $roleIdentifiers, self::AUTHENTICATION_PROVIDER_NAME);
     $user->addAccount($account);
     return $user;
 }
コード例 #3
0
ファイル: AccountFactory.php プロジェクト: putheakhem/login
 /**
  * @param string $email
  * @param string $name
  * @param string $password
  * @param string $imageId
  * @param string $imageId
  * @throws \InvalidArgumentException
  * @return \Ag\Login\Domain\Model\Account
  */
 public function create($email, $name = '', $password = '', $imageId = '')
 {
     $validation = $this->emailAddressValidator->validate($email);
     if ($validation->hasErrors()) {
         throw new \InvalidArgumentException('Email "' . $email . '" is not valid.');
     }
     $password = trim($password);
     if (empty($password)) {
         $password = \Ag\Utility\TokenGenerator::generateToken(32);
     }
     $login = $this->accountFactory->createAccountWithPassword($email, $password);
     return new \Ag\Login\Domain\Model\Account($login, $name, $imageId);
 }
コード例 #4
0
 /**
  * Adds a new account to the system.
  *
  * @param string $username The username of the new administrator
  * @param string $password The password of the new administrator
  */
 public function createAdminUserCommand($username = '', $password = '')
 {
     // check if user + password are not empty
     if ($username == '' || $password == '') {
         // add a console output
         $this->outputLine('Either username or password missing, cannot continue.');
         return 1;
     }
     // let's create the user
     $account = $this->accountFactory->createAccountWithPassword($username, $password, array('Roketi.Panel:Administrator'));
     $this->accountRepository->add($account);
     $this->outputLine('User ' . $username . ' created successfully.');
 }
コード例 #5
0
 /**
  * @param string $identifier
  * @param string $password
  * @return void
  */
 public function createAction($identifier, $password)
 {
     if ($this->accountRepository->countByAccountIdentifier($identifier) == 1 && $this->userRepository->countByUsername($identifier) == 1) {
         $this->addFlashMessage('Nickname already taken, please choose another one!');
         $this->redirect('new');
     } else {
         $account = $this->accountFactory->createAccountWithPassword($identifier, $password);
         $this->accountRepository->add($account);
         $user = new User();
         $user->setUsername($identifier);
         $this->userRepository->add($user);
         $this->addFlashMessage('Account ' . $identifier . ' successful created! You can login now!');
         $this->redirect('index', 'Authentication');
     }
 }
コード例 #6
0
 /**
  * Import Bearbeiter table into the FLOW domain_model tabel subugoe_germaniasacra_domain_model_bearbeiter and creates an account for every user
  * @return int
  */
 private function importAndJoinBearbeiterWithAccount()
 {
     /** @var \Doctrine\DBAL\Connection $sqlConnection */
     $sqlConnection = $this->entityManager->getConnection();
     $sql = 'SELECT ID, Bearbeiter FROM Bearbeiter ORDER BY ID ASC';
     $bearbeiters = $sqlConnection->fetchAll($sql);
     if (isset($bearbeiters) and is_array($bearbeiters)) {
         $nBearbeiter = 0;
         foreach ($bearbeiters as $be) {
             $uid = $be['ID'];
             $bearbeiter = $be['Bearbeiter'];
             $userName = $this->createUsername($bearbeiter);
             $password = $this->createPassword();
             $account = $this->accountFactory->createAccountWithPassword($userName, $password, ['Flow.Login:Administrator']);
             $this->accountRepository->add($account);
             $bearbeiterObject = new Bearbeiter();
             $bearbeiterObject->setUid($uid);
             $bearbeiterObject->setBearbeiter($bearbeiter);
             $bearbeiterObject->setAccount($account);
             $this->bearbeiterRepository->add($bearbeiterObject);
             $this->persistenceManager->persistAll();
             $this->createUsernamePasswordFile($userName, $password, $uid);
             $nBearbeiter++;
         }
         return $nBearbeiter;
     }
 }
コード例 #7
0
 /**
  * Creates a user based on the given information
  *
  * The created user and account are automatically added to their respective repositories and thus be persisted.
  *
  * @param User $user
  * @param string $username The username of the user to be created.
  * @param string $password Password of the user to be created
  * @param array $roleIdentifiers A list of role identifiers to assign
  * @return void
  */
 public function addUser(User $user, $username, $password, array $roleIdentifiers = array('Flowpack.Neos.FrontendLogin:User'))
 {
     $account = $this->accountFactory->createAccountWithPassword($username, $password, $roleIdentifiers, self::ACCOUNT_AUTHENTICATION_PROVIDER);
     $user->addAccount($account);
     $this->userRepository->add($user);
     $this->accountRepository->add($account);
 }
コード例 #8
0
 /**
  * @param PersonDto $person
  * @param NodeInterface $userStorageNode
  * @param string $dateOfBirth
  * @param array $password
  * @param string $recaptcha_challenge_field
  * @return void
  *
  * @throws \Exception
  * @throws \TYPO3\Flow\Mvc\Exception\ForwardException
  * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  * @throws \TYPO3\Flow\Security\Exception
  *
  * @Flow\Validate(argumentName="password", type="\TYPO3\Neos\Validation\Validator\PasswordValidator", options={ "allowEmpty"=0, "minimum"=6, "maximum"=255 })
  * @Flow\Validate(argumentName="recaptcha_challenge_field", type="\BuJitsuDo\Authentication\Validation\Validator\CaptchaValidator")
  * @Flow\Validate(argumentName="person.emailAddress", type="\BuJitsuDo\Authentication\Validation\Validator\AccountDoesNotExistsValidator")
  */
 public function registerAction(PersonDto $person, NodeInterface $userStorageNode, $dateOfBirth = NULL, array $password, $recaptcha_challenge_field = '')
 {
     $account = $this->accountFactory->createAccountWithPassword($person->getEmailAddress(), array_shift($password), $this->defaultRoles);
     $party = $this->objectManager->get('\\TYPO3\\Neos\\Domain\\Model\\User');
     if ($dateOfBirth !== NULL) {
         $date = new \DateTime();
         $date->setTimestamp(strtotime($dateOfBirth));
         $person->setDateOfBirth($date);
     }
     if (!$party instanceof AbstractParty) {
         throw new \Exception('The configured className did not result in an object that inherits from AbstractParty.', 1397043150);
     }
     /** @var $party User */
     $party->setName(new PersonName('', $person->getFirstName(), '', $person->getLastName()));
     $this->partyRepository->add($party);
     $account->setParty($party);
     $this->accountRepository->add($account);
     $this->persistenceManager->persistAll();
     $profile = $this->createProfileNode($account, $userStorageNode, $person);
     if ($profile instanceof NodeInterface) {
         $this->forward('show', 'Frontend\\Node', 'TYPO3.Neos', ['node' => $profile]);
     } else {
         throw new \Exception('No profile node returned', 1239187);
     }
 }
コード例 #9
0
ファイル: TokenFactory.php プロジェクト: rfyio/JWT
 /**
  * @return \TYPO3\Flow\Security\Account
  * @throws Exception
  * @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
  */
 protected function generateTokenAccount()
 {
     $account = $this->securityContext->getAccount();
     $tokenAccount = $this->accountFactory->createAccountWithPassword($account->getAccountIdentifier(), Algorithms::generateRandomString(25), array_keys($account->getRoles()), $this->apiToken->getAuthenticationProviderName());
     $this->accountRepository->add($tokenAccount);
     $this->persistenceManager->persistAll();
     return $tokenAccount;
 }
コード例 #10
0
 /**
  * @dataProvider personsDataProvider
  * @test
  */
 public function personsAndAccountPersistingAndRetrievingWorksCorrectly($firstName, $middleName, $lastName, $emailAddress)
 {
     $person = new Domain\Model\Person();
     $person->setName(new Domain\Model\PersonName('', $firstName, $middleName, $lastName));
     $electronicAddress = new Domain\Model\ElectronicAddress();
     $electronicAddress->setType(Domain\Model\ElectronicAddress::TYPE_EMAIL);
     $electronicAddress->setIdentifier($emailAddress);
     $person->setPrimaryElectronicAddress($electronicAddress);
     $account = $this->accountFactory->createAccountWithPassword($emailAddress, $this->persistenceManager->getIdentifierByObject($person));
     $this->accountRepository->add($account);
     $person->addAccount($account);
     $this->partyRepository->add($person);
     $this->persistenceManager->persistAll();
     $this->assertEquals(1, $this->partyRepository->countAll());
     $this->persistenceManager->clearState();
     $foundPerson = $this->partyRepository->findByIdentifier($this->persistenceManager->getIdentifierByObject($person));
     $this->assertEquals($foundPerson->getName()->getFullName(), $person->getName()->getFullName());
     $this->assertEquals($foundPerson->getName()->getFullName(), $firstName . ' ' . $middleName . ' ' . $lastName);
     $this->assertEquals($foundPerson->getPrimaryElectronicAddress()->getIdentifier(), $emailAddress);
 }
コード例 #11
0
 /**
  * save the registration
  * @param string $name
  * @param string $pass
  * @param string $pass2
  * @param string $role
  */
 public function createAction($name, $pass, $pass2, $role)
 {
     if ($name == '' || strlen($name) < 3) {
         $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Username too short or empty'));
         $this->redirect('register', 'Login');
     } else {
         if ($pass == '' || $pass != $pass2) {
             $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Password too short or does not match'));
             $this->redirect('register', 'Login');
         } else {
             // create a account with password an add it to the accountRepository
             $account = $this->accountFactory->createAccountWithPassword($name, $pass, array($role));
             $this->accountRepository->add($account);
             // add a message and redirect to the login form
             $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Account created. Please login.'));
             $this->redirect('index');
         }
     }
     // redirect to the login form
     $this->redirect('index', 'Login');
 }
コード例 #12
0
 /**
  * Return an OPAuth account.
  * If an account with the given data does not exist a new account will be created.
  *
  * @param \Hfrahmann\Opauth\Opauth\Response $opauthResponse
  * @return \TYPO3\Flow\Security\Account
  * @throws \Hfrahmann\Opauth\Exception
  */
 public function getAccount(\Hfrahmann\Opauth\Opauth\Response $opauthResponse)
 {
     if ($opauthResponse == NULL) {
         throw new \Hfrahmann\Opauth\Exception("OpauthResponse cannot be NULL.", 1381596921);
     }
     $accountIdentifier = $this->createAccountIdentifier($opauthResponse);
     $authenticationProviderName = $this->configuration->getAuthenticationProviderName();
     $account = $this->accountRepository->findByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName);
     if ($account === NULL) {
         $roleIdentifier = $this->configuration->getDefaultRoleIdentifier();
         $roleIdentifierArray = array();
         if (is_array($roleIdentifier)) {
             $roleIdentifierArray = $roleIdentifier;
         }
         if (is_string($roleIdentifier)) {
             $roleIdentifierArray = array($roleIdentifier);
         }
         $account = $this->accountFactory->createAccountWithPassword($accountIdentifier, NULL, $roleIdentifierArray, $authenticationProviderName);
     }
     return $account;
 }
コード例 #13
0
 /**
  * @param \DLigo\Animaltool\Domain\Model\User $newUser
  * @param array $username
  * @Flow\Validate(argumentName="$username", type="notEmpty")   
  * @param array $password
  * @param string $role
  * @Flow\Validate(argumentName="$password", type="\DLigo\Animaltool\Validation\Validator\PasswordValidator")   
  * @Flow\Validate(argumentName="$newUser", type="UniqueEntity")
  * @Flow\Validate(argumentName="$username", type="\DLigo\Animaltool\Validation\Validator\AccountExistsValidator")   
  * @return void
  */
 public function createAction(User $newUser, $username, $password, $role)
 {
     $account = $this->accountFactory->createAccountWithPassword($username['new'], $password[0], array($role));
     $accountApp = $this->accountFactory->createAccountWithPassword($username['new'], $password[0], array($role), 'AppProvider');
     $account->setParty($newUser);
     $accountApp->setParty($newUser);
     $this->accountRepository->add($account);
     $this->accountRepository->add($accountApp);
     $this->userRepository->add($newUser);
     $this->addFlashMessage('Created a new user.', '', \TYPO3\Flow\Error\Message::SEVERITY_OK, array(), 'flash.user.new');
     $this->redirect('index');
 }
コード例 #14
0
 /**
  * Adds a user whose User object has been created elsewhere
  *
  * This method basically "creates" a user like createUser() would, except that it does not create the User
  * object itself. If you need to create the User object elsewhere, for example in your ActionController, make sure
  * to call this method for registering the new user instead of adding it to the PartyRepository manually.
  *
  * This method also creates a new user workspace for the given user if no such workspace exist.
  *
  * @param string $username The username of the user to be created.
  * @param string $password Password of the user to be created
  * @param User $user The pre-built user object to start with
  * @param array $roleIdentifiers A list of role identifiers to assign
  * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider"
  * @return User The same user object
  * @api
  */
 public function addUser($username, $password, User $user, array $roleIdentifiers = null, $authenticationProviderName = null)
 {
     if ($roleIdentifiers === null) {
         $roleIdentifiers = array('TYPO3.Neos:Editor');
     }
     $roleIdentifiers = $this->normalizeRoleIdentifiers($roleIdentifiers);
     $account = $this->accountFactory->createAccountWithPassword($username, $password, $roleIdentifiers, $authenticationProviderName ?: $this->defaultAuthenticationProviderName);
     $this->partyService->assignAccountToParty($account, $user);
     $this->partyRepository->add($user);
     $this->accountRepository->add($account);
     $this->createPersonalWorkspace($user, $account);
     $this->emitUserCreated($user);
     return $user;
 }
コード例 #15
0
 /**
  * Adds a user whose User object has been created elsewhere
  *
  * This method basically "creates" a user like createUser() would, except that it does not create the User
  * object itself. If you need to create the User object elsewhere, for example in your ActionController, make sure
  * to call this method for registering the new user instead of adding it to the PartyRepository manually.
  *
  * This method also creates a new user workspace for the given user if no such workspace exist.
  *
  * @param string $username The username of the user to be created.
  * @param string $password Password of the user to be created
  * @param User $user The pre-built user object to start with
  * @param array $roleIdentifiers A list of role identifiers to assign
  * @param string $authenticationProviderName Name of the authentication provider to use. Example: "Typo3BackendProvider"
  * @return User The same user object
  * @api
  */
 public function addUser($username, $password, User $user, array $roleIdentifiers = NULL, $authenticationProviderName = NULL)
 {
     if ($roleIdentifiers === NULL) {
         $roleIdentifiers = array('TYPO3.Neos:Editor');
     }
     $roleIdentifiers = $this->normalizeRoleIdentifiers($roleIdentifiers);
     $account = $this->accountFactory->createAccountWithPassword($username, $password, $roleIdentifiers, $authenticationProviderName ?: $this->defaultAuthenticationProviderName);
     $user->addAccount($account);
     $this->partyRepository->add($user);
     $this->accountRepository->add($account);
     $this->createUserWorkspace($username);
     $this->emitUserCreated($user);
     return $user;
 }
コード例 #16
0
 /**
  * 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);
 }
コード例 #17
0
 /**
  * Create an admin account
  *
  * Creates a new account which has admin rights.
  *
  * @param string $identifier Account identifier, aka "user name"
  * @param string $password Plain text password for the new account
  * @param string $firstName First name of the account's holder
  * @param string $lastName Last name of the account's holder
  * @return void
  */
 public function createAccountCommand($identifier, $password, $firstName, $lastName)
 {
     $this->initRoles();
     $account = $this->accountFactory->createAccountWithPassword($identifier, $password, array('DLigo.Animaltool:Admin'));
     $accountApp = $this->accountFactory->createAccountWithPassword($identifier, $password, array('DLigo.Animaltool:Admin'), 'AppProvider');
     $user = new \DLigo\Animaltool\Domain\Model\User();
     $user->setFirstname($firstName);
     $user->setLastname($lastName);
     $user->setPhone('');
     $user->setStreet('');
     $user->setNumber('');
     $user->setZipCode('');
     $user->setCity('');
     $user->setRegion('');
     $user->setCountry('');
     $user->setComment('');
     $user->setLastBoxID(0);
     $this->userRepository->add($user);
     $account->setParty($user);
     $accountApp->setParty($user);
     $this->accountRepository->add($account);
     $this->accountRepository->add($accountApp);
     $this->outputLine('The account "%s" was created.', array($identifier));
 }
コード例 #18
0
 /**
  * save the registration
  * @param string $name
  * @param string $pass
  * @param string $pass2
  */
 public function createAction($name, $pass, $pass2)
 {
     $defaultRole = 'Foxxshirts.Druckverwaltung:Visitor';
     if ($name == '' || strlen($name) < 8) {
         $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Benutzername zu kurz oder leer. (min 8 Zeichen)'));
         $this->redirect('register', 'Login');
     } else {
         if ($pass == '' || $pass != $pass2) {
             $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Die Passwoerter stimmen nicht ueberein'));
             $this->redirect('register', 'Login');
         } else {
             // create a account with password an add it to the accountRepository
             $account = $this->accountFactory->createAccountWithPassword($name, $pass, array($defaultRole));
             $this->accountRepository->add($account);
             // add a message and redirect to the login form
             $this->flashMessageContainer->addMessage(new \TYPO3\Flow\Error\Error('Account angelegt. Bitte melden Sie sich an.'));
             $this->redirect('login');
         }
     }
     // redirect to the login form
     $this->redirect('login', 'Login');
 }
コード例 #19
0
 /**
  * Executes this finisher
  * @see AbstractFinisher::execute()
  *
  * @return void
  * @throws \TYPO3\Flow\Mvc\Exception\StopActionException();
  */
 protected function executeInternal()
 {
     /** @var \TYPO3\Form\Core\Runtime\FormRuntime $formRuntime */
     $formRuntime = $this->finisherContext->getFormRuntime();
     $formValueArray = $formRuntime->getFormState()->getFormValues();
     if ($formRuntime->getRequest()->getParentRequest()->getControllerActionName() == 'editDataSheet') {
         // we need to update the data sheet, we assume that the person is authenticated because a data sheet can only be edited by a authenticated user
         /** @var \GIB\GradingTool\Domain\Model\Project $project */
         $project = $this->projectRepository->findByIdentifier($formRuntime->getRequest()->getParentRequest()->getArgument('project'));
         // make a HTML representation of a diff of the old and new data
         $diffContent = DiffUtility::arrayDiffRecursive($project->getDataSheetContentArray(), $formValueArray);
         // store changes to project
         $project->setDataSheetContent($formValueArray);
         $project->setLastUpdated(new \TYPO3\Flow\Utility\Now());
         // update e-mail address (could have changed in the data sheet)
         $projectManagerElectronicAddress = new \TYPO3\Party\Domain\Model\ElectronicAddress();
         $projectManagerElectronicAddress->setIdentifier($formValueArray['projectManagerEmail']);
         $projectManagerElectronicAddress->setType(\TYPO3\Party\Domain\Model\ElectronicAddress::TYPE_EMAIL);
         $project->getProjectManager()->setPrimaryElectronicAddress($projectManagerElectronicAddress);
         $this->partyRepository->update($project->getProjectManager());
         $this->projectRepository->update($project);
         $this->persistenceManager->persistAll();
         // send a notification mail to the Administrator containing the changes
         $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('editDataSheetNotification', $project);
         $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, NULL, '', '', $diffContent);
         // add a flash message
         $message = new \TYPO3\Flow\Error\Message('Your data sheet for project "%s" was successfully edited.', \TYPO3\Flow\Error\Message::SEVERITY_OK, array($project->getProjectTitle()));
         $this->flashMessageContainer->addMessage($message);
     } else {
         // we need to add a new data sheet
         /** @var \GIB\GradingTool\Domain\Model\Project $project */
         $project = new \GIB\GradingTool\Domain\Model\Project();
         $project->setProjectTitle($formValueArray['projectTitle']);
         $project->setDataSheetFormIdentifier($this->settings['forms']['dataSheet']['default']);
         $project->setSubmissionFormIdentifier($this->settings['forms']['submission']['default']);
         // store identifier=userName and password for later usage
         $identifier = $formValueArray['userName'];
         $password = $formValueArray['password'];
         // remove userName and password from data array so it doesn't get saved unencrypted
         unset($formValueArray['userName']);
         unset($formValueArray['password']);
         $project->setDataSheetContent($formValueArray);
         $project->setCreated(new \TYPO3\Flow\Utility\Now());
         $this->projectRepository->add($project);
         // add a flash message
         $message = new \TYPO3\Flow\Error\Message('Your data sheet for project "%s" was successfully submitted.', \TYPO3\Flow\Error\Message::SEVERITY_OK, array($formValueArray['projectTitle']));
         $this->flashMessageContainer->addMessage($message);
         if (!$this->authenticationManager->isAuthenticated() || $this->authenticationManager->isAuthenticated() && $this->authenticationManager->getSecurityContext()->hasRole('GIB.GradingTool:Administrator')) {
             // the product manager (supposedly) doesn't have an account yet, so we create one
             $projectManager = new \GIB\GradingTool\Domain\Model\ProjectManager();
             $projectManagerName = new \TYPO3\Party\Domain\Model\PersonName('', $formValueArray['projectManagerFirstName'], '', $formValueArray['projectManagerLastName']);
             $projectManager->setName($projectManagerName);
             $projectManagerElectronicAddress = new \TYPO3\Party\Domain\Model\ElectronicAddress();
             $projectManagerElectronicAddress->setIdentifier($formValueArray['projectManagerEmail']);
             $projectManagerElectronicAddress->setType(\TYPO3\Party\Domain\Model\ElectronicAddress::TYPE_EMAIL);
             $projectManager->addElectronicAddress($projectManagerElectronicAddress);
             $projectManager->setPrimaryElectronicAddress($projectManagerElectronicAddress);
             // add account
             $roles = array('GIB.GradingTool:ProjectManager');
             $authenticationProviderName = 'DefaultProvider';
             $account = $this->accountFactory->createAccountWithPassword($identifier, $password, $roles, $authenticationProviderName);
             $this->accountRepository->add($account);
             // add account to ProjectManager
             $projectManager->addAccount($account);
             // add project to ProjectManager
             $projectManager->addProject($project);
             // finally add the complete ProjectManager
             $this->partyRepository->add($projectManager);
             if (!$this->authenticationManager->getSecurityContext()->hasRole('GIB.GradingTool:Administrator')) {
                 // authenticate user if no Administrator is authenticated
                 $authenticationTokens = $this->securityContext->getAuthenticationTokensOfType('TYPO3\\Flow\\Security\\Authentication\\Token\\UsernamePassword');
                 if (count($authenticationTokens) === 1) {
                     $authenticationTokens[0]->setAccount($account);
                     $authenticationTokens[0]->setAuthenticationStatus(\TYPO3\Flow\Security\Authentication\TokenInterface::AUTHENTICATION_SUCCESSFUL);
                 }
                 // add a flash message
                 $message = new \TYPO3\Flow\Error\Message('The account "%s" was created and you were successfully logged in.', \TYPO3\Flow\Error\Message::SEVERITY_OK, array($identifier));
                 $this->flashMessageContainer->addMessage($message);
             }
         } elseif ($this->authenticationManager->isAuthenticated() && $this->authenticationManager->getSecurityContext()->hasRole('GIB.GradingTool:ProjectManager')) {
             // a productManager is adding a new project to his account
             /** @var \GIB\GradingTool\Domain\Model\ProjectManager $projectManager */
             $projectManager = $this->authenticationManager->getSecurityContext()->getParty();
             $projectManager->addProject($project);
             $this->partyRepository->update($projectManager);
         }
         $this->persistenceManager->persistAll();
         // send notification mail to project manager (bcc to team)
         $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newDataSheetProjectManagerNotification', $project);
         $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $projectManager, $formValueArray['projectManagerFirstName'] . ' ' . $formValueArray['projectManagerLastName'], $formValueArray['projectManagerEmail']);
         // send notification mail to the GIB team
         $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newDataSheetTeamNotification', $project);
         $dataSheetArray = $this->dataSheetService->getProcessedDataSheet($project);
         $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $projectManager, '', '', $dataSheetArray);
     }
     $this->persistenceManager->persistAll();
     // redirect to dashboard
     $formRuntime = $this->finisherContext->getFormRuntime();
     $request = $formRuntime->getRequest()->getMainRequest();
     $uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder();
     $uriBuilder->setRequest($request);
     $uriBuilder->reset();
     $uri = $uriBuilder->uriFor('editDatasheet', array('project' => $project), 'Project');
     $response = $formRuntime->getResponse();
     $mainResponse = $response;
     while ($response = $response->getParentResponse()) {
         $mainResponse = $response;
     }
     $mainResponse->setStatus(303);
     $mainResponse->setHeader('Location', (string) $uri);
     throw new \TYPO3\Flow\Mvc\Exception\StopActionException();
 }