function it_cannot_send_token_when_email_was_not_valid(ConfirmationSubjectInterface $subject, TokenProviderInterface $tokenProvider) { $tokenProvider->generateUniqueToken()->shouldBeCalled()->willReturn('foobar'); $subject->setConfirmationType('email')->shouldBeCalled(); $subject->confirmationRequest('foobar')->shouldBeCalled(); $subject->getConfirmationChannel('customer.email')->shouldBeCalled()->willReturn('a_invalid_email'); $this->shouldThrow('DoS\\UserBundle\\Confirmation\\Exception\\NotFoundChannelException')->duringSend($subject); }
/** * {@inheritdoc} */ protected function sendToken(ConfirmationSubjectInterface $subject, $token) { $email = $subject->getConfirmationChannel($this->options['channel_path']); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new NotFoundChannelException(); } $this->sender->send($this->options['token_send_template'], array($email), array('subject' => $subject, 'token' => $token)); }
/** * {@inheritdoc} */ protected function sendToken(ConfirmationSubjectInterface $subject, $token) { if (!($mobile = $subject->getConfirmationChannel($this->options['channel_path']))) { throw new NotFoundChannelException(); } $verify = $this->tokenProvider->generateUniqueToken(); $this->sender->send($this->options['token_send_template'], array($mobile), array('subject' => $subject, 'token' => $token, 'verify' => $verify)); /** @var OneTimePasswordInterface $otp */ $otp = new $this->options['otp_class'](); $otp->setSubject($subject); $otp->setToken($token); $otp->setVerify($verify); $this->manager->persist($otp); }
/** * {@inheritdoc} */ public function getSubjectValue(ConfirmationSubjectInterface $subject = null) { if (!$subject) { return; } return $subject->getConfirmationChannel($this->options['channel_path']); }