예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function logIn($email)
 {
     /** @var UserInterface $user */
     $user = $this->userRepository->findOneBy(['username' => $email]);
     if (null === $user) {
         throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email));
     }
     $this->logInUser($user);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function logIn($email, $providerKey, Session $minkSession)
 {
     $user = $this->userRepository->findOneBy(['username' => $email]);
     if (null === $user) {
         throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email));
     }
     $token = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
     $this->session->set('_security_user', serialize($token));
     $this->session->save();
     $minkSession->setCookie($this->session->getName(), $this->session->getId());
 }
 function it_throws_exception_when_there_is_no_user_with_given_username_or_email(UserRepositoryInterface $userRepository, CanonicalizerInterface $canonicalizer)
 {
     $canonicalizer->canonicalize('testUser')->willReturn('testuser');
     $userRepository->findOneBy(['usernameCanonical' => 'testuser'])->willReturn(null);
     $userRepository->findOneByEmail('testuser')->willReturn(null);
     $this->shouldThrow(new UsernameNotFoundException('Username "testuser" does not exist.'))->during('loadUserByUsername', ['testUser']);
 }
예제 #4
0
 function it_does_not_log_user_in_if_user_was_not_found(UserRepositoryInterface $userRepository, SessionInterface $session, CookieSetterInterface $cookieSetter)
 {
     $userRepository->findOneBy(['username' => '*****@*****.**'])->willReturn(null);
     $session->set(Argument::cetera())->shouldNotBeCalled();
     $session->save()->shouldNotBeCalled();
     $cookieSetter->setCookie(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', ['*****@*****.**']);
 }
예제 #5
0
 function it_loads_user_by_user_name(UserRepositoryInterface $userRepository, CanonicalizerInterface $canonicalizer, User $user)
 {
     $canonicalizer->canonicalize('testUser')->willReturn('testuser');
     $userRepository->findOneBy(['usernameCanonical' => 'testuser'])->willReturn($user);
     $this->loadUserByUsername('testUser')->shouldReturn($user);
 }