本文整理匯總了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;
}