JeremyKendall\Password\Decorator\UpgradeDecorator::isValid PHP Метод

isValid() публичный Метод

{@inheritDoc}
public isValid ( $password, $passwordHash, $legacySalt = null, $identity = null )
    public function isValid($password, $passwordHash, $legacySalt = null, $identity = null)
    {
        $isValid = call_user_func($this->validationCallback, $password, $passwordHash, $legacySalt);
        if ($isValid === true) {
            $passwordHash = $this->createHashWhichWillForceRehashInValidator($password);
        }
        return $this->validator->isValid($password, $passwordHash, $legacySalt, $identity);
    }

Usage Example

 public function testLegacyPasswordIsValidUpgradedRehashedWhenClientCodeUsesSameParametersAsUpgradeDecorator()
 {
     $validator = new UpgradeDecorator(new PasswordValidator(), $this->callback);
     $password = '******';
     $hash = hash('sha512', $password);
     $validator->setOptions(array('cost' => UpgradeDecorator::DEFAULT_REHASH_COST));
     $result = $validator->isValid($password, $hash);
     $this->assertTrue($result->isValid(), "Failed asserting that result is valid");
     $this->assertEquals(ValidationResult::SUCCESS_PASSWORD_REHASHED, $result->getCode(), "Failed asserting that password was rehashed");
 }
All Usage Examples Of JeremyKendall\Password\Decorator\UpgradeDecorator::isValid