本文整理汇总了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)));
}