示例#1
0
 /**
  * {@inheritdoc}
  */
 public function updatePassword(CredentialsHolderInterface $user)
 {
     if ('' !== ($password = $user->getPlainPassword())) {
         $user->setPassword($this->userPasswordEncoder->encode($user));
         $user->eraseCredentials();
     }
 }
 function it_encodes_password(EncoderFactoryInterface $encoderFactory, PasswordEncoderInterface $passwordEncoder, CredentialsHolderInterface $user)
 {
     $user->getPlainPassword()->willReturn('topSecretPlainPassword');
     $user->getSalt()->willReturn('typicalSalt');
     $encoderFactory->getEncoder(get_class($user->getWrappedObject()))->willReturn($passwordEncoder);
     $passwordEncoder->encodePassword('topSecretPlainPassword', 'typicalSalt')->willReturn('topSecretEncodedPassword');
     $this->encode($user)->shouldReturn('topSecretEncodedPassword');
 }
示例#3
0
 function it_does_nothing_if_plain_password_is_empty(UserPasswordEncoderInterface $userPasswordEncoder, CredentialsHolderInterface $user)
 {
     $user->getPlainPassword()->willReturn('');
     $userPasswordEncoder->encode($user)->willReturn('topSecretEncodedPassword');
     $user->setPassword(Argument::any())->shouldNotBeCalled();
     $user->eraseCredentials()->shouldNotBeCalled();
     $this->updatePassword($user);
 }
 function it_encodes_password(CredentialsHolderInterface $user)
 {
     $user->getPlainPassword()->willReturn('myPassword');
     $user->getSalt()->willReturn('typicalSalt');
     $this->encode($user)->shouldReturn('G1DuArwJiu+4Ctk9p2965gC3SXjGcom6gNhmV0OGUm79Kb9Anm5GWg==');
 }
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException when the algorithm is not supported
  */
 public function encode(CredentialsHolderInterface $user)
 {
     return $this->encodePassword($user->getPlainPassword(), $user->getSalt());
 }