/**
  * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser
  * @return mixed
  */
 protected function createAndPersistUser(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser)
 {
     // add the user to the default group
     $defaultGroup = $this->frontendUserGroupRepository->findByUid($this->settings['defaults']['globalGroupId']);
     if ($defaultGroup instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup) {
         $frontendUser->addUsergroup($defaultGroup);
     }
     $this->decorateUser($frontendUser, 'created');
     // add the user to the repository
     $this->frontendUserRepository->add($frontendUser);
     $this->flashMessageContainer->add('Your account has been created.');
     // persist the user
     $this->persistenceManager->persistAll();
     return $this->doBehaviors($frontendUser, 'created', 'createConfirmation');
 }
 /**
  * Accepts the forget password form submission and executes behaviors tied to the forgot password
  * event.
  *
  * @param string $emailAddress
  * @validate $emailAddress notEmpty
  * @validate $emailAddress emailAddress
  */
 public function handleForgotPasswordAction($emailAddress)
 {
     // If the extension is configured to not allow forgot password, this action is not allowed.
     if (!$this->settings['login']['allowForgotPassword']) {
         $GLOBALS['TSFE']->pageNotFoundAndExit();
     } else {
         // forgot password is allowed...
         $user = $this->frontendUserRepository->findOneByEmail($emailAddress);
         if (is_object($user) && $user->getUid()) {
             $behaviorsConf = $this->settings['behaviors']['login']['forgotPassword'];
             $this->behaviorService->executeBehaviors($behaviorsConf, $user, $this->controllerContext, 'forgotPassword');
             $this->forward('forgotPassword', NULL, NULL, array('requestProcessed' => true, 'requestSuccessful' => true));
         } else {
             // The developer can decide whether she wants to show feedback in the view when the request was not successful.
             $this->forward('forgotPassword', NULL, NULL, array('requestProcessed' => true, 'requestSuccessful' => false));
         }
     }
 }