Exemple #1
0
 /**
  * @param array $formData
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 protected function executePost(array $formData)
 {
     return $this->actionHelper->handlePostAction(function () use($formData) {
         $this->accountFormValidation->setUserId($this->user->getUserId())->validate($formData);
         $bool = $this->usersModel->save($formData, $this->user->getUserId());
         return $this->redirectMessages()->setMessage($bool, $this->translator->t('system', $bool !== false ? 'edit_success' : 'edit_error'));
     });
 }
Exemple #2
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;
     });
 }
Exemple #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;
     });
 }
Exemple #4
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->accountSettingsFormValidation->setSettings($settings)->validate($formData);
         $formData['time_zone'] = $formData['date_time_zone'];
         if ($settings['language_override'] == 0) {
             unset($formData['language']);
         }
         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, $this->user->getUserId());
         $user = $this->usersModel->getOneById($this->user->getUserId());
         $cookie = $this->authenticationModel->setRememberMeCookie($this->user->getUserId(), $user['remember_me_token']);
         $this->response->headers->setCookie($cookie);
         return $this->redirectMessages()->setMessage($bool, $this->translator->t('system', $bool !== false ? 'settings_success' : 'settings_error'));
     });
 }