Пример #1
0
 /**
  * @param UserInterface $user
  */
 private function logInUser(UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
     $this->session->set($this->sessionTokenVariable, serialize($token));
     $this->session->save();
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }
 function it_should_not_email_disabled_users(FilterUserResponseEvent $event, UserInterface $user, $mailer)
 {
     $user->isEnabled()->willReturn(false);
     $event->getUser()->willReturn($user);
     $mailer->sendCustomerWelcome($user)->shouldNotBeCalled();
     $this->handleEvent($event);
 }
 /**
  * @param UserInterface $user
  */
 protected function handleUserVerificationToken(UserInterface $user)
 {
     $token = $this->tokenGenerator->generate();
     $user->setEmailVerificationToken($token);
     $this->userManager->persist($user);
     $this->userManager->flush();
     $this->eventDispatcher->dispatch(UserEvents::REQUEST_VERIFICATION_TOKEN, new GenericEvent($user));
 }
Пример #4
0
 function it_sends_customer_welcome_email(UserInterface $user, TwigMailerInterface $mailer)
 {
     $parameters = array('template' => 'test-template.html.twig', 'from_email' => '*****@*****.**');
     $this->beConstructedWith($mailer, $parameters);
     $user->getEmail()->willReturn('*****@*****.**');
     $mailer->sendEmail('test-template.html.twig', array('user' => $user), '*****@*****.**', '*****@*****.**')->shouldBeCalled();
     $this->sendCustomerWelcome($user);
 }
 function it_sends_order_confirmation_email(OrderInterface $order, UserInterface $user, TwigMailerInterface $mailer)
 {
     $parameters = array('template' => 'test-template.html.twig', 'from_email' => '*****@*****.**');
     $this->beConstructedWith($mailer, $parameters);
     $user->getEmail()->willReturn('*****@*****.**');
     $order->getUser()->willReturn($user);
     $mailer->sendEmail('test-template.html.twig', array('order' => $order), '*****@*****.**', '*****@*****.**')->shouldBeCalled();
     $this->sendOrderConfirmation($order);
 }
Пример #6
0
 function it_should_connect_oauth_account_with_given_user($userManager, $oauthRepository, UserInterface $user, UserResponseInterface $response, ResourceOwnerInterface $resourceOwner, UserOAuthInterface $oauth)
 {
     $resourceOwner->getName()->willReturn('google');
     $response->getEmail()->willReturn(null);
     $response->getUsername()->willReturn('username');
     $response->getResourceOwner()->willReturn($resourceOwner);
     $response->getAccessToken()->willReturn('access_token');
     $oauthRepository->createNew()->willReturn($oauth);
     $oauth->setIdentifier('username');
     $oauth->setProvider('google');
     $oauth->setAccessToken('access_token');
     $user->addOAuthAccount($oauth)->shouldBeCalled();
     $userManager->updateUser($user)->shouldBeCalled();
     $this->connect($user, $response);
 }
 function it_does_not_update_usernames_when_customer_emails_are_the_same(OnFlushEventArgs $onFlushEventArgs, EntityManager $entityManager, UnitOfWork $unitOfWork, CustomerInterface $customer, UserInterface $user, ClassMetadata $userMetadata)
 {
     $onFlushEventArgs->getEntityManager()->willReturn($entityManager);
     $entityManager->getUnitOfWork()->willReturn($unitOfWork);
     $unitOfWork->getScheduledEntityInsertions()->willReturn([]);
     $unitOfWork->getScheduledEntityUpdates()->willReturn([$customer]);
     $user->getUsername()->willReturn('*****@*****.**');
     $user->getUsernameCanonical()->willReturn('*****@*****.**');
     $customer->getUser()->willReturn($user);
     $customer->getEmail()->willReturn('*****@*****.**');
     $customer->getEmailCanonical()->willReturn('*****@*****.**');
     $user->setUsername(Argument::any())->shouldNotBeCalled();
     $user->setUsernameCanonical(Argument::any())->shouldNotBeCalled();
     $unitOfWork->recomputeSingleEntityChangeSet(Argument::cetera())->shouldNotBeCalled();
     $this->onFlush($onFlushEventArgs);
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function setUser(UserInterface $user = null)
 {
     $this->user = $user;
     if (null !== $this->user) {
         $this->email = $this->user->getEmail();
     }
     return $this;
 }
Пример #9
0
 /**
  * @param array         $authorizationRoles
  * @param UserInterface $user
  */
 protected function assignAuthorizationRoles(UserInterface $user, array $authorizationRoles = array())
 {
     foreach ($authorizationRoles as $role) {
         try {
             $authorizationRole = $this->findOneByName('role', $role);
         } catch (\InvalidArgumentException $exception) {
             $authorizationRole = $this->createAuthorizationRole($role);
             $this->getEntityManager()->persist($authorizationRole);
         }
         $user->addAuthorizationRole($authorizationRole);
     }
 }
Пример #10
0
 /**
  * @param UserInterface $user
  * @param string $role
  * @param string $authorizationRole
  */
 private function addUserRole(UserInterface $user, $role, $authorizationRole)
 {
     $user->addRole($role);
     /** @var RoleInterface $adminRole */
     $adminRole = $this->roleRepository->findOneBy(['code' => $authorizationRole]);
     if (null !== $adminRole) {
         $user->addAuthorizationRole($adminRole);
     }
 }
Пример #11
0
 function it_should_allow_defining_email_from_user(UserInterface $user)
 {
     $user->getEmail()->willReturn('*****@*****.**');
     $this->setUser($user);
     $this->getEmail()->shouldReturn('*****@*****.**');
 }
Пример #12
0
 /**
  * @When /^(I) try to verify my account using the link from this email$/
  */
 public function iUseItToVerify(UserInterface $user)
 {
     $this->verificationPage->verifyAccount($user->getEmailVerificationToken());
 }
Пример #13
0
 /**
  * @param UserInterface $user
  */
 protected function assignCustomer(UserInterface $user = null)
 {
     if (null !== $user) {
         $user->setCustomer($this);
     }
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function sendCustomerWelcome(UserInterface $user)
 {
     $this->sendEmail(array('user' => $user), $user->getEmail());
 }