本文整理汇总了PHP中Credentials::getUserPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Credentials::getUserPassword方法的具体用法?PHP Credentials::getUserPassword怎么用?PHP Credentials::getUserPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Credentials
的用法示例。
在下文中一共展示了Credentials::getUserPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tryLogin
public function tryLogin(Credentials $userCredentials, UserArray $users)
{
//First check to make sure the user is not already logged in (this is also checked in controller, but I prefer to check in all places to minimize errors)
if (!$this->isUserLoggedIn()) {
//If input matches any saved user, return true (successful login attempt) and save in session variable as 'logged in'
if ($users->getUserByName($userCredentials->getUserName()) != null && password_verify($userCredentials->getUserPassword(), $users->getUserByName($userCredentials->getUserName())->getPassword())) {
$_SESSION['LoggedIn'] = $userCredentials->getUserName();
return true;
}
}
//In all other cases, return false
return false;
}