Find by username.
@param  string $username A username.
@return User           The user.
344556
public function findByUsername($username)
    {
        $qb = $this->createQueryBuilder("u");
        $qb->where("(u.username = :username OR u.email = :email)")
            ->setParameter("username", $username)
            ->setParameter("email", $username);
        $qb->andWhere("u.status = :status")->setParameter("status", 1);
        $qb->setMaxResults(1);
        return $qb->getQuery()->getOneOrNullResult();
    }
1277269
public function find($username, array $data = [])
    {
        $response = $this->request->get(sprintf("users/%s", $username), $data);
        return new User($this->master, $response);
    }
528687
public function loadUserByUsername($username)
    {
        $user = $this->segmentalizer->loadUserByUsername($username);
        if (call_user_func($this->filter, $user)) {
            return $user;
        }
        throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
    }
313735
public function find($username)
    {
        $response = $this->search($username);
        foreach ($response->get() as $user) {
            if ($username === $user['username']) {
                return $this->get($user['id']);
            }
        }
        return null;
    }
1027732
private function findUserByUsernameOrThrowException($username)
    {
        $user = $this->userManager->findUserByUsername($username);

        if (!$user) {
            throw new InvalidArgumentException(sprintf('User identified by "%s" username does not exist.', $username));
        }

        return $user;
    }
125700
protected function getUserInfo(string $username)
    {
        if (!isset($this->users[$username])) {
            return null;
        }

        return $this->users[$username];
    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
334719
protected function findUser(OutputInterface $output, string $username): ?User
    {
        try {
            /** @var User $user */

            return $this->userManager->loadUserByUsername($username);
        } catch (UsernameNotFoundException $e) {
            $message = $this->translator->trans(
                'user.does_not_exists',
                ['%username%' => $username],
                'security'
            );
            $output->writeln("<error>{$message}</error>");

            return null;
        }
    }
458525
public function loadUserByUsername($username)
    {
        if (!($username && $this->configSource->has('auth-password/' . $username))) {
            throw new UsernameNotFoundException();
        }

        $userData = $this->configSource->get('auth-password/' . $username);

        return new UserInformation(array_merge($userData, ['username' => $username]));
    }
1236756
protected static function getEmailByUsername($username)
    {
        if (empty($username)) {
            throw new BadRequestException("Missing required username.");
        }

        /** @var User $user */
        $user = User::whereUsername($username)->get(['email'])->first();

        if (empty($user)) {
            throw new NotFoundException('The supplied username was not found in the system.');
        }

        return $user->email;
    }
154306
protected function getUserEntity($userName)
    {
        if (!$userEntity = $this->getRepositoryUsers()->getUser($userName)) {
            $this->flashLogger->error(Trans::__('general.phrase.error-user-name-password-incorrect'));

            return null;
        }

        if (!$userEntity->getEnabled()) {
            $this->systemLogger->alert("Attempt to login with disabled account by '$userName'", ['event' => 'security']);
            $this->flashLogger->error(Trans::__('general.phrase.login-account-disabled'));

            return null;
        }

        return $userEntity;
    }
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;
    }
147100
public function usernameValidator($username)
    {
        if (empty($username)) {
            throw new \Exception('The username can not be empty');
        }

        $userManager = $this->getUserManager();
        if ($userManager->usernameExists($username)) {
            throw new \Exception('The username is already used.');
        }

        return $username;
    }
1158182
public function find($username, $fields = [])
    {
        $this->adldap->utilities()->validateNotNullOrEmpty('Username', $username);

        $personCategory = $this->adldap->getPersonFilter('category');
        $person = $this->adldap->getPersonFilter('person');

        return $this->adldap->search()
            ->select($fields)
            ->where($personCategory, '=', $person)
            ->where('samaccounttype', '=', Adldap::ADLDAP_NORMAL_ACCOUNT)
            ->where('anr', '=', $username)
            ->first();
    }
907371
public function getUser($name)
    {
        $user = $this->find("name", $name);
        $user = $this->setupUser($user);
        return $user;
    }
484879
public function loadUserByUsername($username)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        return $qb
            ->select('u')
            ->from('CiscajaUhsaUserBundle:User', 'u')
            ->where(
                $qb->expr()->orX(
                    $qb->expr()->eq('u.username', ':username'),
                    $qb->expr()->eq('u.email', ':username')
                )
            )
            ->setParameters(array(
                'username' => $username
            ))
            ->getQuery()
            ->getOneOrNullResult();
    }
633053
public function getByUsername($username)
    {
        if (!is_string($username)) {
            return false;
        }

        $data = [
            'where' => [
                [
                    'column' => $this->tableAlias . '.username',
                    'value'  => $username,
                ],
            ],
        ];

        $user = $this->getAll(null, null, $data);

        return empty($user) ? false : $user[0];
    }