/**
  * @param $username
  * @return string
  */
 public function generate($username)
 {
     $this->checkUsername($username);
     do {
         $key = $this->randomStringGenerator->generate();
     } while (!$this->checkKey($key));
     $this->userRepository->addUser($username, $key);
     return $key;
 }