Example #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;
 }
Example #2
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] : [];
 }
 /**
  * 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);
 }