本文整理汇总了PHP中Password::equals方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::equals方法的具体用法?PHP Password::equals怎么用?PHP Password::equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Password
的用法示例。
在下文中一共展示了Password::equals方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: should_test_equality
/** @test */
public function should_test_equality()
{
$one = new Password('qwertyuiop');
$two = new Password('qwertyuiop');
$three = new Password('asdfghjkl');
$this->assertTrue($one->equals($two));
$this->assertFalse($one->equals($three));
}
示例2: checkTemporaryPassword
/**
* Check if the given clear-text password matches the temporary password
* sent by e-mail for password reset operations.
*
* @param string $plaintext
*
* @return bool True if matches, false otherwise
*/
public function checkTemporaryPassword($plaintext)
{
global $wgNewPasswordExpiry;
$this->load();
$this->loadPasswords();
if ($this->mNewpassword->equals($plaintext)) {
if (is_null($this->mNewpassTime)) {
return true;
}
$expiry = wfTimestamp(TS_UNIX, $this->mNewpassTime) + $wgNewPasswordExpiry;
return time() < $expiry;
} else {
return false;
}
}
示例3: matchHash
/**
* @param string $plaintext User-provided password plaintext.
* @param Password $password Password to check against
*
* @return Status
*/
protected function matchHash($plaintext, Password $password)
{
$matched = false;
if ($password->equals($plaintext)) {
$matched = true;
} elseif (!$password instanceof Pbkdf2Password && function_exists('iconv')) {
// Some wikis were converted from ISO 8859-1 to UTF-8;
// retained hashes may contain non-latin chars.
$latin1 = iconv('UTF-8', 'WINDOWS-1252//TRANSLIT', $plaintext);
if ($password->equals($latin1)) {
$matched = true;
}
}
if ($matched) {
return Status::newGood($password);
} else {
return Status::newFatal('bad');
}
}