示例#1
0
 /**
  * @param int $userId
  * @param string $token
  * @return array|int
  * @throws AuthenticationException
  */
 protected function verifyCredentials($userId, $token)
 {
     $user = $this->userRepository->getOneById($userId);
     if (!empty($user) && $user['remember_me_token'] === $token) {
         return $user;
     }
     return 0;
 }
示例#2
0
 /**
  * @return array
  */
 public function execute()
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $resultsPerPage = $this->resultsPerPage->getResultsPerPage(Users\Installer\Schema::MODULE_NAME);
     $allUsers = $this->userRepository->countAll();
     $this->pagination->setResultsPerPage($resultsPerPage)->setTotalResults($allUsers);
     $users = $this->userRepository->getAll($this->pagination->getResultsStartOffset(), $resultsPerPage);
     return ['users' => $users, 'pagination' => $this->pagination->render(), 'all_users' => $allUsers];
 }
示例#3
0
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     if ($this->userRepository->resultExists($id) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $user = $this->user->getUserInfo($id);
         $user['gender'] = str_replace([1, 2, 3], ['', $this->translator->t('users', 'female'), $this->translator->t('users', 'male')], $user['gender']);
         return ['user' => $user];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
示例#4
0
 /**
  * Gibt ein Array mit den angeforderten Daten eines Benutzers zurück
  *
  * @param int $userId
  *
  * @return array
  */
 public function getUserInfo($userId = 0)
 {
     if (empty($userId) && $this->isAuthenticated() === true) {
         $userId = $this->getUserId();
     }
     $userId = (int) $userId;
     if (empty($this->userInfo[$userId])) {
         $countries = Country::worldCountries();
         $info = $this->userRepository->getOneById($userId);
         if (!empty($info)) {
             $info['country_formatted'] = !empty($info['country']) && isset($countries[$info['country']]) ? $countries[$info['country']] : '';
             $this->userInfo[$userId] = $info;
         }
     }
     return !empty($this->userInfo[$userId]) ? $this->userInfo[$userId] : [];
 }
示例#5
0
 /**
  * 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);
 }
示例#6
0
 /**
  * @param string $nickNameOrEmail
  * @return array
  */
 protected function fetchUserByFormFieldValue($nickNameOrEmail)
 {
     if ($this->get('core.validation.validation_rules.email_validation_rule')->isValid($nickNameOrEmail) === true && $this->userRepository->resultExistsByEmail($nickNameOrEmail) === true) {
         $user = $this->userRepository->getOneByEmail($nickNameOrEmail);
     } else {
         $user = $this->userRepository->getOneByNickname($nickNameOrEmail);
     }
     return $user;
 }
示例#7
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());
 }