コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function send(ConfirmationSubjectInterface $subject)
 {
     $subject->confirmationDisableAccess();
     $subject->setConfirmationType($this->getType());
     $subject->confirmationRequest($token = $this->tokenProvider->generateUniqueToken());
     $this->sendToken($subject, $token);
     if (!$this->isValid) {
         return;
     }
     $this->manager->persist($subject);
     $this->manager->flush();
     $this->storage->setData(self::STORE_KEY, $subject->getConfirmationToken());
 }
コード例 #3
0
 /**
  * @param TokenProviderInterface $generator
  * @param UserInterface          $user
  * @param string                 $senderEvent
  *
  * @return Response
  */
 protected function handleResetPasswordRequest(TokenProviderInterface $generator, UserInterface $user, $senderEvent)
 {
     $user->setConfirmationToken($generator->generateUniqueToken());
     $user->setPasswordRequestedAt(new \DateTime());
     $this->domainManager->update($user);
     $dispatcher = $this->get('event_dispatcher');
     $dispatcher->dispatch($senderEvent, new GenericEvent($user));
     if ($this->config->isApiRequest()) {
         return $this->handleView($this->view($user, 204));
     }
     $this->addFlash('success', 'sylius.user.password.reset.success');
     return new RedirectResponse($this->generateUrl('sylius_homepage'));
 }
コード例 #4
0
ファイル: UserController.php プロジェクト: ahmadrabie/Sylius
 /**
  * @param TokenProviderInterface $generator
  * @param UserInterface $user
  * @param string $senderEvent
  *
  * @return Response
  */
 protected function handleResetPasswordRequest(TokenProviderInterface $generator, UserInterface $user, $senderEvent)
 {
     $user->setConfirmationToken($generator->generateUniqueToken());
     $user->setPasswordRequestedAt(new \DateTime());
     /* I have to use doctrine manager directly, because domain manager functions add a flash messages. I can't get rid of them.*/
     $manager = $this->container->get('doctrine.orm.default_entity_manager');
     $manager->persist($user);
     $manager->flush();
     $dispatcher = $this->container->get('event_dispatcher');
     $dispatcher->dispatch($senderEvent, new GenericEvent($user));
 }