Beispiel #1
0
 /**
  * Creates an instance of an entity.
  *
  * This method must return always an empty instance
  *
  * @return AdminUserInterface Empty entity
  */
 public function create()
 {
     /**
      * @var AdminUserInterface $adminUser
      */
     $classNamespace = $this->getEntityNamespace();
     $adminUser = new $classNamespace();
     $adminUser->setToken($this->generator->generate(2))->setEnabled(true)->setCreatedAt(new DateTime());
     return $adminUser;
 }
Beispiel #2
0
 /**
  * Creates an instance of an entity.
  *
  * This method must return always an empty instance
  *
  * @return UserInterface Empty entity
  */
 public function create()
 {
     /**
      * @var UserInterface $adminUser
      */
     $classNamespace = $this->getEntityNamespace();
     $user = new $classNamespace();
     $user->setPassword('newyork2014')->setToken($this->generator->generate(2))->setRoles([])->setEnabled(true)->setCreatedAt(new DateTime());
     return $user;
 }
Beispiel #3
0
 /**
  * Set a user in a remember password mode. Also rises an event
  * to hook when this happens.
  *
  * Recover url must contain these fields with these names
  *
  * @param AbstractUser $user                   User
  * @param string       $recoverPasswordUrlName Recover password name
  * @param string       $hashField              Hash
  *
  * @return $this Self object
  */
 public function rememberPassword(AbstractUser $user, $recoverPasswordUrlName, $hashField = 'hash')
 {
     $recoveryHash = $this->recoveryHashGenerator->generate();
     $user->setRecoveryHash($recoveryHash);
     $this->manager->flush($user);
     $recoverUrl = $this->router->generate($recoverPasswordUrlName, [$hashField => $recoveryHash], true);
     $this->passwordEventDispatcher->dispatchOnPasswordRememberEvent($user, $recoverUrl);
     return $this;
 }
Beispiel #4
0
 /**
  * Generates a random string with entropy.
  *
  * @param int|null $length Length of string generated
  *
  * @return string Result of generation
  */
 public function generate($length = 1)
 {
     return hash('sha1', $this->generator->generate($length));
 }