Example #1
0
 /**
  * @param array $formData
  * @param array $settings
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, array $settings)
 {
     return $this->actionHelper->handlePostAction(function () use($formData, $settings) {
         $this->registrationFormValidation->validate($formData);
         $systemSettings = $this->config->getSettings(Schema::MODULE_NAME);
         $subject = $this->translator->t('users', 'register_mail_subject', ['{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $body = $this->translator->t('users', 'register_mail_message', ['{name}' => $formData['nickname'], '{mail}' => $formData['mail'], '{password}' => $formData['pwd'], '{title}' => $systemSettings['site_title'], '{host}' => $this->request->getHost()]);
         $mailIsSent = $this->sendEmail->execute('', $formData['mail'], $settings['mail'], $subject, $body);
         $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $insertValues = ['id' => '', 'nickname' => $this->get('core.helpers.secure')->strEncode($formData['nickname']), 'pwd' => $this->secureHelper->generateSaltedPassword($salt, $formData['pwd'], 'sha512'), 'pwd_salt' => $salt, 'mail' => $formData['mail'], 'date_format_long' => $systemSettings['date_format_long'], 'date_format_short' => $systemSettings['date_format_short'], 'time_zone' => $systemSettings['date_time_zone'], 'language' => $systemSettings['lang'], 'registration_date' => $this->date->getCurrentDateTime()];
         $lastId = $this->userRepository->insert($insertValues);
         $bool2 = $this->permissionsHelpers->updateUserRoles([2], $lastId);
         $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('users', $mailIsSent === true && $lastId !== false && $bool2 !== false ? 'register_success' : 'register_error'), $this->appPath->getWebRoot()));
     }, $this->request->getFullPath());
 }