Finds user by [[username]] or [[email]]

@return User|null
188369
protected function getUser()
    {
        if ($this->_user === null) {
            $this->_user = Admin::findByEmailOrMobileOrUsername($this->login);
        }
        return $this->_user;
    }
1019836
public function findTokenByEmail($email)
    {
        $user = $this->users->where('email', $email)->first();

        if (! is_null($user)) {
            return $user->getActivationToken();
        }

        return null;
    }
847027
public function getUser()
    {
        if ($this->_user === false) {
            $this->_user = User::findByKeyfield($this->username);
        }
        return $this->_user;
    }
718908
public function getAuthor()
    {
        $user = null;

        if($this->hasProperty('created_by') && !empty($this->created_by)) {
            $user = $this->getObject('user.provider')->getUser($this->created_by);
        }

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

        return $this->users[$username];
    }
412223
public function findUserByUsernameOrEmail($usernameOrEmail)
    {
        if (filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL)) {
            return $this->findUserByEmail($usernameOrEmail);
        }

        return $this->findUserByUsername($usernameOrEmail);
    }
131942
private function findUser($username)
    {
        $userManager = $this->getContainer()->get('phlexible_user.user_manager');

        $user = $userManager->find($username);

        if (!$user) {
            $user = $userManager->findByUsername($username);
        }

        if (!$user) {
            return null;
        }

        return $user;
    }
191589
public function getUserEmail($info = NULL) {
    if (empty($info)) {
      $info = $this->getUserInfo();
    }
    $emails = $info->get('emails');
    if (is_array($emails) && count($emails)) {
      $email = reset($emails);
      return $email['value'];
    }
  }
991280
public function findUser() {
        $model = ClassRegistry::init($this->usersModel);
        $id = trim($this->in('User ID:'));

        if (!$id) {
            $this->out('<error>Invalid ID, please try again</error>');
            return $this->findUser();
        }

        $result = $model->find('first', array(
            'conditions' => array($model->alias . '.' . $model->primaryKey => $id),
            'recursive' => -1
        ));

        if (!$result) {
            $this->out('<error>User does not exist, please try again</error>');
            return $this->findUser();
        }

        $this->user = $result;

        return $id;
    }
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();
    }
1262287
private function emailToUsername($email = null)
    {
        if ($user = get_user_by('email', $email)) {
            if (isset($user->user_login)) {
                return $user->user_login;
            }
        }

        return null;
    }
325216
def find_user_by_username(self, username):
        """"""
        return self.db_adapter.ifind_first_object(self.UserClass, username=username)
734899
public function findUser(array $params)
    {
        /** @var UserProvider $userProvider */
        $userProvider = $this->container[UserProvider::class];
        try {
            /** @var User $user */
            $user = $userProvider->loadUserByUsername($params['username']);
        } catch(\Exception $e) {
            return false;
        }
        return $user;
    }
540153
public function checkUsername() {
    if (!Tilmeld::$config['email_usernames']) {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify a username.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Usernames must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }
      if (array_diff(
          str_split($this->username),
          str_split(Tilmeld::$config['valid_chars'])
      )) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_chars_notice']
        ];
      }
      if (!preg_match(Tilmeld::$config['valid_regex'], $this->username)) {
        return [
          'result' => false,
          'message' => Tilmeld::$config['valid_regex_notice']
        ];
      }
      $selector = ['&',
        'ilike' => [
          'username',
          str_replace(
              ['\\', '%', '_'],
              ['\\\\\\\\', '\%', '\_'],
              $this->username
          )
        ]
      ];
      if (isset($this->guid)) {
        $selector['!guid'] = $this->guid;
      }
      $test = Nymph::getEntity(
          ['class' => '\Tilmeld\Entities\User', 'skip_ac' => true],
          $selector
      );
      if (isset($test->guid)) {
        return ['result' => false, 'message' => 'That username is taken.'];
      }

      return [
        'result' => true,
        'message' => (
          isset($this->guid) ? 'Username is valid.' : 'Username is available!'
        )
      ];
    } else {
      if (empty($this->username)) {
        return ['result' => false, 'message' => 'Please specify an email.'];
      }
      if (Tilmeld::$config['max_username_length'] > 0
          && strlen($this->username) > Tilmeld::$config['max_username_length']
        ) {
        return [
          'result' => false,
          'message' => 'Emails must not exceed '.
            Tilmeld::$config['max_username_length'].' characters.'
        ];
      }

      return $this->checkEmail();
    }
  }
1338928
public function getUserByName($username)
    {
        return $this->getUsers()->then(function (array $users) use ($username) {
            foreach ($users as $user) {
                if ($user->getUsername() === $username) {
                    return $user;
                }
            }

            throw new UserNotFoundException("The user \"$username\" does not exist.");
        });
    }
449691
public function getUserID($usernameOrEmail)
    {
        $user = get_user_by(is_email($usernameOrEmail) ? 'email' : 'login', $usernameOrEmail);

        if (is_object($user) && isset($user->ID)) {
            return $user->ID;
        }

        return null;
    }
884707
public function getEmail(){
		$result = null;
		if (isset($this->userInfo[$this->socialFieldsMap['email']])) {
			$result = $this->userInfo[$this->socialFieldsMap['email']];
			}
		return $result;
		}