Example #1
0
 function it_logs_user_in($securityContext, $userChecker, $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(array('ROLE_TEST'));
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $securityContext->setToken(Argument::type('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken'))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type('Sylius\\Bundle\\UserBundle\\Event\\UserEvent'))->shouldBeCalled();
     $this->login($user);
 }
Example #2
0
 function it_logs_user_in(TokenStorageInterface $tokenStorage, UserCheckerInterface $userChecker, EventDispatcherInterface $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(['ROLE_TEST']);
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $userChecker->checkPostAuth($user)->shouldBeCalled();
     $tokenStorage->setToken(Argument::type(UsernamePasswordToken::class))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type(UserEvent::class))->shouldBeCalled();
     $this->login($user);
 }
Example #3
0
 function it_logs_user_in($securityContext, $userChecker, $eventDispatcher, UserInterface $user)
 {
     $user->getRoles()->willReturn(array('ROLE_TEST'));
     $userChecker->checkPreAuth($user)->shouldBeCalled();
     $userChecker->checkPostAuth($user)->shouldBeCalled();
     $securityContext->setToken(Argument::type(UsernamePasswordToken::class))->shouldBeCalled();
     $eventDispatcher->dispatch(UserEvents::SECURITY_IMPLICIT_LOGIN, Argument::type(UserEvent::class))->shouldBeCalled();
     $this->login($user);
 }
Example #4
0
 function it_does_not_log_user_in_if_user_was_not_found($userRepository, $session, UserInterface $user, Session $minkSession)
 {
     $userRoles = ['ROLE_USER'];
     $userRepository->findOneBy(array('username' => '*****@*****.**'))->willReturn(null);
     $user->getRoles()->willReturn($userRoles);
     $user->getPassword()->willReturn('xyz');
     $user->serialize()->willReturn('serialized_user');
     $session->set('_security_user', Argument::any())->shouldNotBeCalled();
     $session->save()->shouldNotBeCalled();
     $session->getName()->willReturn('MOCKEDSID');
     $session->getId()->willReturn('xyzc123');
     $minkSession->setCookie('MOCKEDSID', 'xyzc123')->shouldNotBeCalled();
     $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', array('*****@*****.**', 'default', $minkSession));
 }
Example #5
0
 /**
  * @param UserInterface $user
  * @param string        $firewallName
  *
  * @return UsernamePasswordToken
  */
 protected function createToken(UserInterface $user, $firewallName)
 {
     return new UsernamePasswordToken($user, null, $firewallName, $user->getRoles());
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function logIn(UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
     $this->setToken($token);
 }
Example #7
0
 /**
  * @param UserInterface $user
  */
 private function logUserIn(UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
     $serializedToken = serialize($token);
     $this->setSerializedToken($serializedToken);
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }