本文整理匯總了PHP中PasswordHash::comparePasswordFallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP PasswordHash::comparePasswordFallback方法的具體用法?PHP PasswordHash::comparePasswordFallback怎麽用?PHP PasswordHash::comparePasswordFallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PasswordHash
的用法示例。
在下文中一共展示了PasswordHash::comparePasswordFallback方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
public function login($sUsername, $sPassword)
{
$oUser = UserQuery::create()->filterByUsername($sUsername)->findOne();
if ($oUser === null) {
$oUser = UserQuery::create()->filterByEmail($sUsername)->find();
if (count($oUser) === 1) {
$oUser = $oUser[0];
} else {
return 0;
}
}
if (!PasswordHash::comparePassword($sPassword, $oUser->getPassword())) {
if (PasswordHash::comparePasswordFallback($sPassword, $oUser->getPassword())) {
$oUser->setPassword($sPassword);
UserPeer::ignoreRights(true);
$oUser->save();
return $this->login($sUsername, $sPassword);
}
if ($oUser->getPassword() === '*') {
return self::USER_NEEDS_PASSWORD_RESET;
}
return 0;
}
if ($oUser->getDigestHA1() === null && Settings::getSetting('security', 'generate_digest_secrets', false) === true) {
$oUser->setPassword($sPassword);
UserPeer::ignoreRights(true);
$oUser->save();
}
return $this->loginUser($oUser);
}
示例2: testSimplePasswordCheckFallback
public function testSimplePasswordCheckFallback()
{
$sPassword = <<<EOT
myTestPassword
EOT;
$this->assertSame(true, PasswordHash::comparePasswordFallback($sPassword, md5($sPassword)));
}