/**
  * @param $username
  * @return User|null
  */
 private function findUser($username)
 {
     $criteria = array("username" => $username);
     return $this->userRepository->findOneBy($criteria);
 }
 /**
  * @param string $username
  * @return User|null
  */
 public function findByUsername($username)
 {
     $criteria = ["username" => $username];
     return $this->userRepository->findOneBy($criteria);
 }