示例#1
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handleCreatePostAction(function () use($formData) {
         $this->adminFormValidation->validate($formData);
         $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
         $formData = array_merge($formData, ['pwd' => $this->secureHelper->generateSaltedPassword($salt, $formData['pwd'], 'sha512'), 'pwd_salt' => $salt, 'time_zone' => $formData['date_time_zone'], 'registration_date' => 'now']);
         $lastId = $this->usersModel->save($formData);
         $this->permissionsHelpers->updateUserRoles($formData['roles'], $lastId);
         return $lastId;
     });
 }
示例#2
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());
 }
示例#3
0
 /**
  * @param array $formData
  * @param int $userId
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData, $userId)
 {
     return $this->actionHelper->handleEditPostAction(function () use($formData, $userId) {
         $this->adminFormValidation->setUserId($userId)->validate($formData);
         $formData['time_zone'] = $formData['date_time_zone'];
         $this->permissionsHelpers->updateUserRoles($formData['roles'], $userId);
         if (!empty($formData['new_pwd']) && !empty($formData['new_pwd_repeat'])) {
             $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH);
             $newPassword = $this->secureHelper->generateSaltedPassword($salt, $formData['new_pwd'], 'sha512');
             $formData['pwd'] = $newPassword;
             $formData['pwd_salt'] = $salt;
         }
         $bool = $this->usersModel->save($formData, $userId);
         $this->updateCurrentlyLoggedInUserCookie($userId);
         return $bool;
     });
 }