/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $password * @validate $password \CIC\Cicregister\Validation\Validator\PasswordValidator */ public function createAction(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, array $password) { $frontendUser->setPassword($password[0]); $behaviorResponse = $this->createAndPersistUser($frontendUser); $results = new \stdClass(); $results->hasErrors = false; switch (get_class($behaviorResponse)) { case 'CIC\\Cicregister\\Behaviors\\Response\\RenderAction': $viewObjectName = 'CIC\\Cicregister\\View\\FrontendUserJSON\\' . $behaviorResponse->getValue(); $view = $this->objectManager->create($this->defaultViewObjectName); $this->setViewConfiguration($view); $view->setControllerContext($this->controllerContext); $view->assign('settings', $this->settings); // same with settings injection. $this->controllerContext->getRequest()->setFormat('html'); $out = $view->render($behaviorResponse->getValue() . ''); $this->controllerContext->getRequest()->setFormat('json'); $results->html = $out; break; case 'CIC\\Cicregister\\Behaviors\\Response\\RedirectAction': $uriBuilder = $this->controllerContext->getUriBuilder(); $uri = $uriBuilder->reset()->setTargetPageUid($this->settings['pids']['editView'])->setNoCache(false)->setUseCacheHash(false)->uriFor($behaviorResponse->getValue(), NULL, 'FrontendUser'); $results->redirect = $uri; break; case 'CIC\\Cicregister\\Behaviors\\Response\\RedirectURI': $results->redirect = $behaviorResponse->getValue(); break; } $this->view->assign('results', json_encode($results)); }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $conf */ public function decorate(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, $conf = array()) { $groupUid = $conf['groupUid']; if ($groupUid) { $group = $this->frontendUserGroupRepository->findByUid($groupUid); if ($group instanceof \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup) { $frontendUser->addUsergroup($group); } } }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $conf * @return string */ public function execute(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, array $conf) { $recipients = array($frontendUser->getEmail() => $frontendUser->getName()); $sender = array($conf['senderEmail'] => $conf['senderName']); $subject = $conf['validateSubject']; $templateName = 'ForgotPassword.html'; $variables = $conf['variables']; $variables['frontendUser'] = $frontendUser; $variables['validationKey'] = $this->emailValidator->generateKey($frontendUser); $this->sendTemplateEmail($recipients, $sender, $subject, $templateName, $variables); }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $conf * @return string */ public function execute(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, array $conf) { // This method generates a login hash, which gets validated in the authentication service. // The login hash is part of a query string that the user is redirected to. $hashValidator = $this->objectManager->get('CIC\\Cicregister\\Service\\HashValidator'); $loginHash = $hashValidator->generateShortLivedKey($frontendUser->getUid()); $uriBuilder = $this->controllerContext->getUriBuilder(); $returnUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('return_url'); $uri = $uriBuilder->reset()->setTargetPageUid($conf['forwardPid'])->setLinkAccessRestrictedPages(true)->setNoCache(false)->setUseCacheHash(false)->setArguments(array('return_url' => $returnUrl, 'logintype' => 'login', 'pid' => $conf['feuserPid'], 'loginHash' => $loginHash))->uriFor($conf['forwardAction'], NULL, 'FrontendUser'); $response = $this->objectManager->create('CIC\\Cicregister\\Behaviors\\Response\\RedirectURI'); $response->setValue($uri); return $response; }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $conf * @return string */ public function execute(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, array $conf) { $recipients = array($frontendUser->getEmail() => $frontendUser->getName()); $sender = array($conf['senderEmail'] => $conf['senderName']); $subject = $conf['validateSubject']; $templateName = 'ValidateEmail.html'; $variables = $conf['variables']; $variables['frontendUser'] = $frontendUser; $variables['validationKey'] = $this->emailValidator->generateKey($frontendUser); $this->sendTemplateEmail($recipients, $sender, $subject, $templateName, $variables); $response = $this->objectManager->create('CIC\\Cicregister\\Behaviors\\Response\\RenderAction'); $response->setValue('createConfirmationMustValidate'); return $response; }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param null $rand * @return string */ public function generateKey(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, $rand = NULL) { if (!$rand) { $rand = mt_rand(); } $base = $this->salt . $frontendUser->getUid() . $rand . $frontendUser->getEmail(); $hash = md5($base); $key = $hash . '-' . $frontendUser->getUid() . '-' . $rand; return $key; }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $conf */ public function decorate(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, $conf = array()) { $frontendUser->setDisable(false); }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @param array $otherData * @param array $password * @validate $password \CIC\Cicregister\Validation\Validator\PasswordValidator(allowEmpty = true) */ public function updateAction(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser, $otherData = array(), array $password = NULL) { if ($password != NULL && is_array($password) && $password[0] != false) { $frontendUser->setPassword($password[0]); } $this->decorateUser($frontendUser, 'updated'); // emit a signal prior to saving the user. $this->signalSlotDispatcher->dispatch(__CLASS__, 'updateAction', array('frontendUser' => $frontendUser, $otherData)); $this->frontendUserRepository->update($frontendUser); $this->flashMessageContainer->add('Your profile has been updated.'); $this->handleBehaviorResponse($this->doBehaviors($frontendUser, 'updated', 'edit'), $frontendUser); }
/** * @param \CIC\Cicregister\Domain\Model\FrontendUser $frontendUser * @return sObject */ protected function createSfContact(\CIC\Cicregister\Domain\Model\FrontendUser $frontendUser) { $SFObj = new sObject(); $SFObj->type = 'Contact'; $SFObj->fields['FirstName'] = $frontendUser->getFirstName(); $SFObj->fields['LastName'] = $frontendUser->getLastName(); $SFObj->fields['Email'] = $frontendUser->getEmail(); $SFObj->fields['Phone'] = $frontendUser->getTelephone(); $SFObj->fields['MailingCity'] = $frontendUser->getCity(); $SFObj->fields['MailingCountry'] = $frontendUser->getCountry(); $SFObj->fields['MailingPostalCode'] = $frontendUser->getZip(); $SFObj->fields['MailingStreet'] = $frontendUser->getAddress(); $SFObj->fields['Title'] = $frontendUser->getTitle(); $this->createSfContactChild($SFObj, $frontendUser); return $SFObj; }
/** * @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'); }