Ejemplo n.º 1
0
 /**
  * Creates new password recovery token and sends it to the user.
  *
  * @param User $user user object
  * @return bool whether the recovery information was sent.
  */
 public function sendRecoveryToken(User $user)
 {
     /** @var Token $tokenClass */
     $tokenClass = $this->module->tokenModel;
     $expireTime = $this->module->passwordRecoveryTokenExpiration;
     $expireTime = $expireTime !== null ? (new DateTime())->modify('+' . $expireTime) : null;
     $token = $tokenClass::generate($user->getId(), $tokenClass::TYPE_PASSWORD_RECOVERY, $expireTime);
     return $this->mailer->sendPasswordRecoveryEmail($user, $token);
 }