/**
  * @param UserDataEvent $event
  */
 public function onRequestedPassword(UserDataEvent $event)
 {
     $user = $event->getUser();
     $token = $this->tokenGenerator->generateToken();
     $this->userManager->updateConfirmationTokenUser($user, $token);
     $message = \Swift_Message::newInstance()->setCharset('UTF-8')->setSubject($this->templating->loadTemplate($this->template)->renderBlock('subject', []))->setFrom($this->from)->setTo($user->getEmail())->setBody($this->templating->loadTemplate($this->template)->renderBlock('body', ['username' => $user->getUsername(), 'request_link' => $this->router->generate('reset_password', ['token' => $token], true)]));
     $this->mailer->send($message);
 }
 protected function setToken(User $user)
 {
     if (!$user->isTokenValid()) {
         $user->setConfirmationToken($this->tokenGenerator->generateToken());
     }
     $user->setConfirmationTokenValidTill($this->getValidTill());
     return $user;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function refreshToken($tokenId)
 {
     $value = $this->generator->generateToken();
     $this->storage->setToken($tokenId, $value);
     return new CsrfToken($tokenId, $value);
 }