Fetches the user from slack

@param string $username
@return null|object|BaseUser
160265
public function loadUserByUsername($username)
    {
        $slackUser = $this->client->getSlackUserFromOAuthCode($username);

        if (!$slackUser->isValid()) {
            throw new UsernameNotFoundException('No access token found.');
        }

        $user = $this->userService->findBySlackUserId($slackUser->getUserId());

        if (!empty($user)) {
            return $user;
        }

        $user = $this->userService->findUserByEmail($slackUser->getEmail());

        if (!empty($user)) {
            $user->setSlackUserId($slackUser->getUserId());

            return $user;
        }

        return $this->registerUser($slackUser);
    }
685466
public static function getByLogin($username)
    {    
        $fields = self::getDbConnection()->fetchAssoc( 'SELECT * FROM '.User::TABLE.' WHERE login = ?', array( $username ) );
        if (!$fields) return false;
        return self::fetch($fields);    
  	}
634630
public function loadUserByUsername($username)
    {

        $users = $this->userData->listEntries([$this->usernameField => $username], [$this->usernameField => '='], 0, 1);
        if (count($users) === 0) {
            throw new UsernameNotFoundException();
        }

        $user = $users[0];
        $roles = is_string($this->userRoleIdentifier) ? $this->loadUserRolesViaManyToMany($user) : $this->loadUserRolesViaData($user->get('id'));

        $userObj = new User($this->usernameField, $this->passwordField, $this->saltField, $user, $roles);
        return $userObj;
    }
1034384
public function getUser($username)
    {
        try {
            $response = $this->client->adminGetUser([
                'Username' => $username,
                'UserPoolId' => $this->userPoolId,
            ]);
            return $response;
        } catch (Exception $e) {
            throw CognitoResponseException::createFromCognitoException($e);
        }
    }
1257844
public function loadUserByUsername($username)
    {
        if ($username) {
            $password = '...';
            $salt = "";
            $roles = ["ROLE_USER"];

            return new CasUser($username, $password, $salt, $roles);
        }

        throw new UsernameNotFoundException(
            sprintf('Username "%s" does not exist.', $username)
        );
    }
907371
public function getUser($name)
    {
        $user = $this->find("name", $name);
        $user = $this->setupUser($user);
        return $user;
    }
698292
function get_userinfo_asobj($username) {
        $user_array = truncate_userinfo($this->get_userinfo($username));
        $user = new stdClass();
        foreach($user_array as $key=>$value) {
            $user->{$key} = $value;
        }
        return $user;
    }
154989
public function findAvatars($username)
    {
        $parameters['username'] = $username;
        return $this->apiClient->callEndpoint(sprintf('%s/avatars', self::ENDPOINT), $parameters);
    }
908541
private function findByUsername(string $username)
    {
        if ($this->userRepository instanceof UserRepositoryInterface) {
            return $this->userRepository->findByUsername($username);
        }

        return $this->userRepository->findOneBy(['username' => $username]);
    }
829909
private function getLDAPUser($username)
    {
        $adldap = false;
        $adUser = false;

        try {
            $ldapQuery = Settings::get('eloquent-ldap.user_filter');
            if (strpos($ldapQuery, self::USER_TOKEN)) {
                $ldapQuery = str_replace(self::USER_TOKEN, $username, $ldapQuery);
            }
            else {
                throw new \Exception("Invalid AD/LDAP query filter, check the configuration of 'LDAP_USER_FILTER'.");
            }

            $ldapFields = [
                Settings::get('eloquent-ldap.username_field'),
                Settings::get('eloquent-ldap.first_name_field'),
                Settings::get('eloquent-ldap.last_name_field'),
                Settings::get('eloquent-ldap.email_field'),
                'useraccountcontrol',
                'dn',
            ];

            // Build connection info.
            $ldapConOp = $this->GetLDAPConnectionOptions();

            if (Settings::get('eloquent-ldap.debug')) {
                // Set LDAP debug log level - useful in DEV, dangerous in PROD!!
                ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
            }

            // Connect to AD/LDAP
            $adldap = new Adldap();
            $adldap->addProvider($ldapConOp);
            $provider = $adldap->connect();

            // Search...
            $adUser = $provider->search()->select($ldapFields)->rawFilter($ldapQuery)->first();
//            $adResults = $provider->search()->select($ldapFields)->rawFilter($ldapQuery)->get();
//
//            if (isset($adResults) && is_array($adResults) && isset($adResults[0])) {
//                $adResults = $adResults[0];
//            }

            if (!$adUser) {
                $this->handleLDAPError($adldap);
            }
        } catch (\Exception $ex) {
            Log::error('Exception retrieving user information: ' . $ex->getMessage());
            Log::error($ex->getTraceAsString());
        }

        // Close connection.
        if (isset($provider)) {
            unset($provider);
        }
        // Close connection.
        if (isset($adldap)) {
            unset($adldap);
        }

        return $adUser;
    }
949106
public function getUserByUsername($username)
    {
        $return = array();

        $users = $this->repository->users;
        foreach ($users as $user) {
            if ($user->username == $username) {
                $return = $user;
                break;
            }
        }

        return $return;
    }
1242301
public function loadUserByUsername($username)
    {
        /** @var User|UserInterface $user */
        $user = $this->getRepository()->findOneBy(['username' => $username]);
        if (!$user && $this->allowEmailAsUsername) {
            $user = $this->getRepository()->findOneBy(['email' => $username]);
        }
        if ($user) {
            return $user;
        }

        throw new UsernameNotFoundException($username);
    }
766810
public static function findByUsername($username)
    {
        foreach (self::$users as $user) {
            if (strcasecmp($user['username'], $username) === 0) {
                return new static($user);
            }
        }

        return null;
    }
297311
public function requestPwReset($username) {
  $setting = new Setting;
  $site_name = $setting->get('site_name');
  $user = $this->get($username, 'username');
  $uid = $this->getSecureID();
  // This has to manually add the resource as Resource/add doesn't have a way to specifiy a userID, it has to be derived from a SID.
  $req = new \JohnVanOrange\Core\Request;
  $data = [
   'ip' => $req->ip(),
   'user_id' => $user['id'],
   'value' => $uid,
   'type' => 'pwreset',
   'public' => 0
  ];
  $query = new \Peyote\Insert('resources');
  $query->columns(array_keys($data))
        ->values(array_values($data));
  $this->db->fetch($query);
  //need to get email address from db as $user->get doesn't return it for security reasons
  $query = new \Peyote\Select('users');
  $query->columns('email')
        ->where('username', '=', $username);
  $email = $this->db->fetch($query);
  $message = new Mail();
  $data = [
   'username'  => $user['username'],
   'reset_key' => $uid
  ];
  $message->sendMessage([$email[0]['email']], 'Password reset request for '. $site_name, 'pwreset', $data);
  return array(
   'message' => 'Reset email sent'
  );
 }
736358
protected function getUser()
    {
        if ($this->_user === null) {
            $this->_user = User::findByUsername($this->username);
        }

        return $this->_user;
    }
270251
public function load($username): UserInterface
    {
        $grav = Grav::instance();
        /** @var UniformResourceLocator $locator */
        $locator = $grav['locator'];

        // force lowercase of username
        $username = mb_strtolower($username);

        $filename = 'account://' . $username . YAML_EXT;
        $path = $locator->findResource($filename) ?: $locator->findResource($filename, true, true);
        $file = CompiledYamlFile::instance($path);
        $content = (array)$file->content() + ['username' => $username, 'state' => 'enabled'];

        $userClass = $this->className;
        $callable = function() {
            $blueprints = new Blueprints;

            return $blueprints->get('user/account');
        };

        /** @var UserInterface $user */
        $user = new $userClass($content, $callable);
        $user->file($file);

        return $user;
    }
180880
public function getSingleUser(string $username): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/users/:username', $username));
    }