function it_should_update_password_from_plain($encoder, MemberInterface $member) { $encoder->encodePassword('plain_password', 'salt')->shouldBeCalled()->willReturn('password_encoded'); $member->getPlainPassword()->shouldBeCalled()->willReturn('plain_password'); $member->getSalt()->shouldBeCalled()->willReturn('salt'); $member->setPassword('password_encoded')->shouldBeCalled(); $member->eraseCredentials()->shouldBeCalled(); $this->updatePassword($member); }
/** * Updates member password * * @param MemberInterface $member */ public function updatePassword(MemberInterface $member) { if (0 !== strlen($password = $member->getPlainPassword())) { $encoder = $this->getEncoder(); $member->setPassword($encoder->encodePassword($password, $member->getSalt())); $member->eraseCredentials(); } }