/** * Erzeugt das Captchafeld für das Template * * @param integer $captchaLength * @param string $formFieldId * @param bool $inputOnly * @param string $path * * @return string */ public function captcha($captchaLength = self::CAPTCHA_DEFAULT_LENGTH, $formFieldId = self::CAPTCHA_DEFAULT_INPUT_ID, $inputOnly = false, $path = '') { if ($this->user->isAuthenticated() === false) { $path = sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path)); $this->sessionHandler->set('captcha_' . $path, $this->secureHelper->salt($captchaLength)); $this->view->assign('captcha', ['width' => $captchaLength * 25, 'id' => $formFieldId, 'height' => 30, 'input_only' => $inputOnly, 'path' => $path]); return $this->view->fetchTemplate('Captcha/Partials/captcha.tpl'); } return ''; }
/** * @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; }); }
/** * Migrates the old sha1 based password hash to sha512 hashes and returns the updated user information * * @param int $userId * @param string $password * * @return array */ private function migratePasswordHashToSha512($userId, $password) { $salt = $this->secureHelper->salt(self::SALT_LENGTH); $updateValues = ['pwd' => $this->secureHelper->generateSaltedPassword($salt, $password, 'sha512'), 'pwd_salt' => $salt]; $this->userRepository->update($updateValues, $userId); return $this->userRepository->getOneById($userId); }
/** * @param array $formData * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function executePost(array $formData) { return $this->actionHelper->handlePostAction(function () use($formData) { $this->accountForgotPasswordFormValidation->validate($formData); $newPassword = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH); $user = $this->fetchUserByFormFieldValue($formData['nick_mail']); $mailIsSent = $this->sendPasswordChangeEmail($user, $newPassword); // Das Passwort des Benutzers nur abändern, wenn die E-Mail erfolgreich versendet werden konnte if ($mailIsSent === true) { $salt = $this->secureHelper->salt(Users\Model\UserModel::SALT_LENGTH); $updateValues = ['pwd' => $this->secureHelper->generateSaltedPassword($salt, $newPassword, 'sha512'), 'pwd_salt' => $salt, 'login_errors' => 0]; $bool = $this->userRepository->update($updateValues, $user['id']); } $this->setTemplate($this->get('core.helpers.alerts')->confirmBox($this->translator->t('users', $mailIsSent === true && isset($bool) && $bool !== false ? 'forgot_pwd_success' : 'forgot_pwd_error'), $this->appPath->getWebRoot())); }, $this->request->getFullPath()); }
/** * @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()); }
/** * @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; }); }
/** * @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')); }); }