本文整理匯總了PHP中Nette\Security\User::getBy方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getBy方法的具體用法?PHP User::getBy怎麽用?PHP User::getBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Security\User
的用法示例。
在下文中一共展示了User::getBy方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: authenticate
public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
$loginData = $this->localLoginModel->getBy(array("user.email" => $username));
if (!$loginData) {
throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND);
} elseif (!Passwords::verify($password, $loginData["password"])) {
throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
} elseif (Passwords::needsRehash($loginData["password"])) {
$this->localLoginModel->update($loginData->user_id, array("password" => Passwords::hash($password)));
}
$identity = $this->buildIdentity($loginData->user_id);
$enabled = $identity->getData()["enabled"];
if (!$enabled) {
throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE);
}
$this->user->login($identity);
}
示例2: authenticate
public function authenticate(array $credentials)
{
list($username, $password) = $credentials;
$loginData = $this->imapLoginModel->getBy(array("username" => $username));
$mbox = imap_open("{localhost:993/ssl/novalidate-cert}INBOX", $username, $password, OP_HALFOPEN | OP_SILENT);
imap_alerts();
imap_errors();
if (!$loginData) {
throw new \Nette\Security\AuthenticationException('Neznámé jméno uživatele.', self::IDENTITY_NOT_FOUND);
} elseif (!$mbox) {
throw new \Nette\Security\AuthenticationException('Nesprávné heslo.', self::INVALID_CREDENTIAL);
}
$identity = $this->buildIdentity($loginData->user_id);
$enabled = $identity->getData()["enabled"];
if (!$enabled) {
throw new \Nette\Security\AuthenticationException('Tento účet je zablokovaný.', self::INACTIVE);
}
$this->user->login($identity);
}