本文整理汇总了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);
}