本文整理汇总了PHP中Sentry::checkHash方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::checkHash方法的具体用法?PHP Sentry::checkHash怎么用?PHP Sentry::checkHash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::checkHash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPasswordNeverUsed
private function checkPasswordNeverUsed($user_id, $password)
{
$falseLogin = false;
try {
if (Sentry::getUser() === NULL) {
// Need to login a user because Sentry checkHash
// works only when a user is logged in.
$falseLogin = true;
$user = Sentry::findUserById($user_id);
// Temporarily log the user in
Sentry::login($user, false);
}
} catch (\RuntimeException $e) {
// echo 'Error getting/logging in User';
}
$used_passwords = UsedPassword::userId($user_id)->get()->toArray();
foreach ($used_passwords as $key => $data) {
try {
if (Sentry::checkHash($password, $data['password'])) {
// This password was used in the past
if ($falseLogin) {
Sentry::logout();
}
// Logout the temporary logged in user
return FALSE;
}
} catch (\RuntimeException $e) {
// echo 'Error using Sentry checkHash';
}
}
if ($falseLogin) {
Sentry::logout();
}
// Logout the temporary logged in user
return TRUE;
}